forked from maniero/SOpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvertParamenter.java
More file actions
32 lines (27 loc) · 884 Bytes
/
Copy pathInvertParamenter.java
File metadata and controls
32 lines (27 loc) · 884 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public static void copiaDestino(File origem, File destino) throws IOException{
FileChannel inChannel = new FileInputStream(origem).getChannel();
FileChannel outChannel = new FileOutputStream(destino).getChannel();
try{
int maxCont = (64 * 1024 * 1024) - (32 * 1024);
long size = inChannel.size();
long position = 0;
while (position < size){
position += inChannel.transferTo(position, size, outChannel);
}
}finally{
if(inChannel != null){
inChannel.close();
}
if(outChannel != null){
outChannel.close();
}
}
//No main():
try {
File origem = new File("C:\\Novapasta\\server.sql");
File destino = new File("C:\\t");
copiaDestino(origem, destino)
} catch (Exception ex) { //isto só é útil aqui porque é o main
System.out.println("Deu erro");
}
//https://pt.stackoverflow.com/q/82783/101