mercredi 11 janvier 2017

Java - Write 100 random words to a file - method

I need to implement a method here that return 100 random words from a file. Any ideas or help how to do so? Below is the rest of my code.

public class DZ14Z02 {
private File file;
private BufferedWriter bw;
private BufferedReader br;
Random r = new Random();


public DZ14Z02(File file) throws IOException{
    this.bw = new BufferedWriter(new FileWriter(file));
    this.br = new BufferedReader(new FileReader(file));
    this.file = file;
}

public void writeInFile(String text) throws IOException{
    bw.write(text);
    bw.flush();
}

public void randomWords() throws IOException{

}

public void resetReader() throws FileNotFoundException {
    br = new BufferedReader(new FileReader(file));
}
public void setFile(File file){
    this.file = file;
}}




Aucun commentaire:

Enregistrer un commentaire