Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class BuffFileCopy {
- /**
- * @param args
- */
- public static void main(String[] args) throws IOException {
- FileInputStream inFile = null;
- FileOutputStream outFile = null;
- BufferedInputStream inBuff =null;
- BufferedOutputStream outBuffO =null;
- try {
- // Поток ввода соединяется с буфером
- inFile = new FileInputStream("c:\\bufffilecopy\\ubuntu-12.04-beta1-desktop-i386.iso");
- inBuff = new BufferedInputStream(inFile);
- // Поток вывода соединяется с буфером
- outFile = new FileOutputStream("c:\\bufffilecopy2\\ubuntu-12.04-beta1-desktop-i386.iso");
- outBuffO = new BufferedOutputStream(outFile);
- while (true) {
- // Считывается байт данных и записывается
- // в буфер вывода данных
- int intValueOfByte = inBuff.read();
- outBuffO.write(intValueOfByte);
- if (intValueOfByte == -1){
- break;
- }
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally{
- try{
- // Сброс данных в поток вывода и
- // закритие потоков
- outBuffO.flush();
- inBuff.close();
- inFile.close();
- outFile.close();
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment