Skip to content

Instantly share code, notes, and snippets.

@no1fushi
Last active June 2, 2020 05:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save no1fushi/881f9b5578d7750698ae5668d964295d to your computer and use it in GitHub Desktop.
Save no1fushi/881f9b5578d7750698ae5668d964295d to your computer and use it in GitHub Desktop.
public String openFile() {
String fn = "";
String all = "";
try {
FileReader fr = new FileReader(fn);
BufferedReader br = new BufferedReader(fr);
String buf;
while ((buf = br.readLine()) != null) {
all += buf;
all += System.getProperty("line.separator");
}
br.close();
fr.close();
} catch (Exception e) {
System.out.println("Error reading file");
System.exit(1);
}
return all;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment