radko93 icon

buforowe

radko93 | PRO | 02/05/13 08:16:35 PM UTC | 0 ⭐ | 288 👁️ | Never ⏰ | []
Java |

880 B

|

None

|

0 👍

/

0 👎

import java.util.*;
import java.io.*;
 
public class kbajtowe {
    int licznik = 0;
    Scanner sc = new Scanner(System.in);
 
    String f1 = sc.nextLine();
    String f2 = sc.nextLine();
 
    public void kopiuj(String f1, String f2) {
        try {
            
            BufferedInputStream br1 = new BufferedInputStream(
                    new FileInputStream(f1));
            BufferedOutputStream br2 = new BufferedOutputStream(
                    new FileOutputStream(f2));
            BufferedInputStream br3 = new BufferedInputStream(
                    new FileInputStream(f1));
 
            while (br1.read()!=-1) {
                br2.write(br3.read());
                licznik++;
            }
            System.out.printf("%s%7d", "Liczba bajtow:", licznik);
            br1.close();
            br2.close();
        }
 
        catch (IOException e) {
            System.out.println(e);
        }
    }
 
    public static void main(String[] args) {
        System.out.println("Wprowadz nazwy plikow");
        kbajtowe test = new kbajtowe();
        test.kopiuj(test.f1, test.f2);
 
    }
 
}

Comments