Abonner på:
Innlegg
Kommentarer

Administrasjon:
Log in
Skriv et innlegg

readFromFile

/** readFromFile.
method to read from file
@param filname filename to read information from
@return file as a String
*/
String[] readFromFile(String filename) {
String[] posts = new String[numbersOfElephants];
try {
FileReader fileReader = new FileReader(filename);
BufferedReader textReader = new BufferedReader(fileReader);
String tmp ="";
System.out.println("readFromFile starter");
for (int i = 0; i < numbersOfElephants; i++) {
System.out.println("leser linje " + i);
tmp = textReader.readLine();
if (tmp == null) break;
System.out.println(tmp);
posts[i] = tmp;
}
textReader.close();
fileReader.close();
}
catch (IOException ioe) {
System.out.println(ioe);
}
return posts;
}

Svar på innlegg

Du må være logget inn for å kommentere.