radko93

bajtowe

Feb 5th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3.  
  4. public class kbajtowe {
  5.     int licznik = 0;
  6.     Scanner sc = new Scanner(System.in);
  7.  
  8.     String f1 = sc.nextLine();
  9.     String f2 = sc.nextLine();
  10.  
  11.     public void kopiuj(String f1, String f2) {
  12.         try {
  13.  
  14.             BufferedInputStream br1 = new BufferedInputStream(
  15.                     new FileInputStream(f1));
  16.             BufferedOutputStream br2 = new BufferedOutputStream(
  17.                     new FileOutputStream(f2));
  18.  
  19.             while (br1.read() != -1) {
  20.                 br2.write(br1.read());
  21.                 licznik++;
  22.             }
  23.             System.out.printf("%s%7d", "Liczba bajtow:", licznik);
  24.             br1.close();
  25.             br2.close();
  26.         }
  27.  
  28.         catch (IOException e) {
  29.             System.out.println(e);
  30.         }
  31.     }
  32.  
  33.     public static void main(String[] args) {
  34.         System.out.println("Wprowadz nazwy plikow");
  35.         kbajtowe test = new kbajtowe();
  36.         test.kopiuj(test.f1, test.f2);
  37.  
  38.     }
  39.  
  40. }
Advertisement
Add Comment
Please, Sign In to add comment