Created
March 25, 2017 00:55
-
-
Save rokon12/a937eb37850c964d64b1589d4ef592dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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