KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > backup > CopyFile


1 package com.daffodilwoods.daffodildb.server.backup;
2
3 import com.daffodilwoods.database.resource.DException;
4 import java.io.*;
5
6 public class CopyFile {
7   public CopyFile() {
8   }
9
10   public void copyFile(FileInputStream file, FileOutputStream DestinationFile) throws
11       DException {
12     try {
13       byte[] bytes = new byte[50000];
14       int size = 0;
15       while ( (size = file.read(bytes)) != -1) {
16         DestinationFile.write(bytes, 0, size);
17       }
18       DestinationFile.close();
19     }
20     catch (IOException ex) {
21     }
22   }
23
24   public void copyFile(RandomAccessFile file, RandomAccessFile DestinationFile) throws
25       DException {
26     try {
27       byte[] bytes = new byte[50000];
28       int size = 0;
29       file.seek(0);
30       DestinationFile.seek(0);
31       while ( (size = file.read(bytes)) != -1) {
32         DestinationFile.write(bytes, 0, size);
33       }
34       DestinationFile.close();
35     }
36     catch (IOException ex) {
37     }
38   }
39 }
40
Popular Tags