Skip to content

Instantly share code, notes, and snippets.

@rokon12
Created March 25, 2017 00:56
Show Gist options
  • Save rokon12/f817a0de6ac6cb637fdc345addf7fa58 to your computer and use it in GitHub Desktop.
Save rokon12/f817a0de6ac6cb637fdc345addf7fa58 to your computer and use it in GitHub Desktop.
import java.io.FileInputStream;
import java.io.IOException;
public class FilePrinter {
private static void printFileJava7() {
try (FileInputStream fis = new FileInputStream("file.txt")) {
int data;
while ((data = fis.read()) != -1) {
System.out.print((char) data);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment