Skip to content

Instantly share code, notes, and snippets.

@rahul-rkt
Created June 7, 2012 20:03
Show Gist options
  • Save rahul-rkt/2891239 to your computer and use it in GitHub Desktop.
Save rahul-rkt/2891239 to your computer and use it in GitHub Desktop.
Traditional way of reading files in Java
package test.file.reading;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
public class TraditionalJava {
public static void main(String[] args) throws IOException {
String line, fileString = "";
BufferedReader bufferedReader = new BufferedReader(new FileReader(new File("test.txt")));
while (null != (line = bufferedReader.readLine())) {
fileString += line + "\n";
}
System.out.println(fileString);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment