Skip to content

Instantly share code, notes, and snippets.

@uncoded-ro
Last active June 13, 2022 13:46
Show Gist options
  • Save uncoded-ro/ca0100f2aff513d9be8f265663063b0a to your computer and use it in GitHub Desktop.
Save uncoded-ro/ca0100f2aff513d9be8f265663063b0a to your computer and use it in GitHub Desktop.
package ro.virtualcampus.read;
import java.io.*;
public class ReadFromFile {
public static void main(String args[]) {
BufferedReader fin = null;
try {
fin = new BufferedReader(new FileReader("in.txt"));
String buffer;
while ((buffer = fin.readLine()) != null) {
System.out.println(buffer);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (fin != null)
fin.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment