Advertisement
Guest User

Untitled

a guest
Feb 7th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.10 KB | None | 0 0
  1. import java.io.*;
  2. public class CopyFile {
  3.  
  4.    public static void main(String args[]) throws IOException {  
  5.       FileInputStream in = null;
  6.       FileOutputStream out = null;
  7.  
  8.       try {
  9.          in = new FileInputStream("input.txt");
  10.          out = new FileOutputStream("output.txt");
  11.          
  12.          int c;
  13.          while ((c = in.read()) != -1) {
  14.             out.write(c);
  15.          }
  16.       }finally {
  17.          if (in != null) {
  18.             in.close();
  19.          }
  20.          if (out != null) {
  21.             out.close();
  22.          }
  23.       }
  24.    }
  25. }
  26.  
  27.  
  28.  
  29. import java.io.*;
  30. public class CopyFile {
  31.  
  32.    public static void main(String args[]) throws IOException {
  33.       FileReader in = null;
  34.       FileWriter out = null;
  35.  
  36.       try {
  37.          in = new FileReader("input.txt");
  38.          out = new FileWriter("output.txt");
  39.          
  40.          int c;
  41.          while ((c = in.read()) != -1) {
  42.             out.write(c);
  43.          }
  44.       }finally {
  45.          if (in != null) {
  46.             in.close();
  47.          }
  48.          if (out != null) {
  49.             out.close();
  50.          }
  51.       }
  52.    }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement