Skip to content

Instantly share code, notes, and snippets.

@ollien
Created November 20, 2014 05:08
Show Gist options
  • Save ollien/aaeba4ada5bde26e503f to your computer and use it in GitHub Desktop.
Save ollien/aaeba4ada5bde26e503f to your computer and use it in GitHub Desktop.
Read Files with Java
try{
BufferedReader reader = new BufferedReader(new FileReader("fileName.txt"));
String line = "";
while ((line = reader.readLine())!=null){
//Do something with the line, say store it in an array
}
reader.close();
}
catch (FileNotFoundException e){
e.printStackTrace();
}
catch (IOException e){
e.printStackTrace();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment