Skip to content

Instantly share code, notes, and snippets.

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