S
santanuguha2006
how to read a .txt file?
how to read a .txt file?
.....private String filereader(FileInputStream is ) {
catch (Exception e) {
System.out.println("Error in file reader: " + e);
return "Error";
}
how to read a .txt file?
Depending on your needs, either:
BufferedReader reader = new BufferedReader(new FileReader(...));
for (; {
String line = reader.readLine();
if (line == null) break;
...
}
reader.close();
or
Scanner scanner = new Scanner(...);
while (scanner.hasNext()) {
int i = scanner.nextInt(); // or whatever
...
}
scanner.close();
Pawel said:
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.