Guest User

Untitled

a guest
Oct 25th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. public static void main(String[] args) throws Exception {
  2. FileInputStream inputStream = new FileInputStream("c:/data.txt");
  3. FileOutputStream outputStream = new FileOutputStream("c:/result.txt");
  4.  
  5. byte[] buffer = new byte[1000];
  6. while (inputStream.available() > 0){
  7.  
  8. int count = inputStream.read(buffer);
  9. outputStream.write(buffer, 0, count);
  10. }
  11.  
  12. inputStream.close();
  13. outputStream.close();
  14. }
  15.  
  16. private void writeFile(File file, byte[] bytes) {
  17. BufferedOutputStream bos = null;
  18.  
  19. try {
  20. bos = new BufferedOutputStream(new FileOutputStream(file));
  21. bos.write(bytes);
  22. } catch (IOException e) {
  23. e.printStackTrace();
  24. } finally {
  25. if (image != null) {
  26. image.close();
  27. }
  28. if (null != bos) {
  29. try {
  30. bos.close();
  31. } catch (IOException e) {
  32. e.printStackTrace();
  33. }
  34. }
  35. }
  36. }
Add Comment
Please, Sign In to add comment