Skip to content

Instantly share code, notes, and snippets.

@golenishchev
Last active December 28, 2015 05:20
Show Gist options
  • Save golenishchev/663eaf9363e343f4d884 to your computer and use it in GitHub Desktop.
Save golenishchev/663eaf9363e343f4d884 to your computer and use it in GitHub Desktop.
Lesson 13. FileInputStream, FileOutputStream
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class FileManager {
public static void main(String[] args) throws Exception {
FileInputStream fin = new FileInputStream("first.txt");
FileOutputStream fout = new FileOutputStream("second.txt");
int i = -1;
while((i = fin.read()) != -1) {
System.out.print("byte: " + (byte)i + "\tchar: " + (char)i + "\n");
fout.write((byte)i);
}
fin.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment