FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
java-code-example/CopyFiles/src/copyfiles/Main.java at master · cherkavi/java-code-example · GitHub
cherkavi
/
java-code-example
Public
Notifications
You must be signed in to change notification settings
Fork
4
Star
0
Code
Issues
0
Pull requests
42
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
java-code-example
/
CopyFiles
/
src
/
copyfiles
/
Main.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
52 lines (45 loc) · 1.39 KB
Breadcrumbs
java-code-example
/
CopyFiles
/
src
/
copyfiles
/
Main.java
Copy path
File metadata and controls
executable file
·
52 lines (45 loc) · 1.39 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package
copyfiles
;
import
java
.
io
.*;
/**
*
* @author cherkashinv
*/
public
class
Main
{
/**
* @param args the command line arguments
*/
public
static
void
main
(
String
[]
args
) {
// TODO code application logic here
copyFile
(
"c:
\\
test.xml"
,
"c:
\\
2.xml"
);
}
private
static
boolean
copyFile
(
String
source
,
String
destination
){
boolean
return_value
=
false
;
try
{
File
file_source
=
new
File
(
source
);
File
file_destination
=
new
File
(
destination
);
InputStream
in
=
new
FileInputStream
(
file_source
);
//For Append the file.
// OutputStream out = new FileOutputStream(f2,true);
//For Overwrite the file.
OutputStream
out
=
new
FileOutputStream
(
file_destination
);
// buffer size
byte
[]
buf
=
new
byte
[
1024
];
int
len
;
while
((
len
=
in
.
read
(
buf
)) >
0
){
out
.
write
(
buf
,
0
,
len
);
}
in
.
close
();
out
.
close
();
return_value
=
true
;
}
catch
(
FileNotFoundException
ex
){
System
.
out
.
println
(
"File ("
+
source
+
") not found: "
+
ex
.
getMessage
());
}
catch
(
IOException
e
){
System
.
out
.
println
(
"IOException:"
+
e
.
getMessage
());
}
return
return_value
;
}
}
Back
|
FazBrowse Home
|
New Git URL