Skip to content

Instantly share code, notes, and snippets.

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 juniorcesarabreu/5014c5dc46ba780dc9b927bf887829a8 to your computer and use it in GitHub Desktop.
Save juniorcesarabreu/5014c5dc46ba780dc9b927bf887829a8 to your computer and use it in GitHub Desktop.
read complete file without using loop in java
File file = new File("a.txt");
FileInputStream fis = new FileInputStream(file);
byte[] data = new byte[(int) file.length()];
fis.read(data);
fis.close();
String str = new String(data, "UTF-8");
// https://stackoverflow.com/questions/14169661/read-complete-file-without-using-loop-in-java
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment