Created
June 7, 2012 20:03
-
-
Save rahul-rkt/2891239 to your computer and use it in GitHub Desktop.
Traditional way of reading files in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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