Skip to content

Instantly share code, notes, and snippets.

@nobeans
Created December 7, 2010 16:20
Show Gist options
  • Save nobeans/731986 to your computer and use it in GitHub Desktop.
Save nobeans/731986 to your computer and use it in GitHub Desktop.
import java.io.*;
class Hoge {
public static void main(String[] args) throws Exception {
try (BufferedInputStream is = new BufferedInputStream( new FileInputStream(new File("/tmp/hoge")));
BufferedOutputStream os = new BufferedOutputStream(new FileOutputStream(new File("/tmp/foo")))) {
int length = 0;
byte[] buffer = new byte[1024];
while ((length = is.read(buffer)) >= 0) {
System.out.write(buffer, 0, length);
os.write(buffer, 0, length);
}
}
System.out.println("Done.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment