FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
File-Copier-in-Java/FileCopy.java at master · soheshdoshi/File-Copier-in-Java · GitHub
soheshdoshi
/
File-Copier-in-Java
Public
Notifications
You must be signed in to change notification settings
Fork
1
Star
0
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
File-Copier-in-Java
/
FileCopy.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
75 lines (62 loc) · 2.46 KB
Breadcrumbs
File-Copier-in-Java
/
FileCopy.java
Copy path
File metadata and controls
75 lines (62 loc) · 2.46 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import
java
.
util
.*;
import
java
.
io
.*;
public
class
FileCopy
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
Scanner
s
=
new
Scanner
(
System
.
in
);
System
.
out
.
println
(
"Enter the InputPath"
);
String
inputPath
=
s
.
nextLine
();
System
.
out
.
println
(
"Enter the OutputPath"
);
String
outputPath
=
s
.
nextLine
();
System
.
out
.
println
(
"Enter File Name:-"
);
String
fileName
=
s
.
nextLine
();
fileCopier
(
inputPath
,
outputPath
,
fileName
);
}
static
void
fileCopier
(
String
inputPath
,
String
outputPath
,
String
fileName
)
throws
FileNotFoundException
,
IOException
{
File
inputFile
=
new
File
(
inputPath
+
"
\\
"
+
fileName
);
File
outputFile
=
new
File
(
outputPath
+
"
\\
"
+
fileName
);
File
temp
=
null
;
FileReader
readFile
=
null
;
FileWriter
writeFile
=
null
;
readFile
=
new
FileReader
(
inputPath
+
"
\\
"
+
fileName
);
if
(
inputFile
.
exists
()){
if
(
outputFile
.
exists
()){
temp
=
new
File
(
outputPath
+
"
\\
"
+
fileName
.
substring
(
0
,
fileName
.
indexOf
(
"."
))+
" - Copy"
+
fileName
.
substring
(
fileName
.
indexOf
(
"."
),
fileName
.
length
()));
if
(
temp
.
exists
()){
int
i
=
2
;
int
a
;
while
(
true
){
temp
=
new
File
(
outputPath
+
"
\\
"
+
fileName
.
substring
(
0
,
fileName
.
indexOf
(
"."
))+
" - Copy ("
+
i
+
")"
+
fileName
.
substring
(
fileName
.
indexOf
(
"."
),
fileName
.
length
()));
if
(!
temp
.
exists
()){
break
;
}
i
++;
}
writeFile
=
new
FileWriter
(
outputPath
+
"
\\
"
+
fileName
.
substring
(
0
,
fileName
.
indexOf
(
"."
))+
" - Copy ("
+
i
+
")"
+
fileName
.
substring
(
fileName
.
indexOf
(
"."
),
fileName
.
length
()));
while
((
a
=
readFile
.
read
())!=-
1
){
writeFile
.
write
(
a
);
}
System
.
out
.
println
(
"Successfully."
);
}
else
{
int
a
;
writeFile
=
new
FileWriter
(
outputPath
+
"
\\
"
+
fileName
.
substring
(
0
,
fileName
.
indexOf
(
"."
))+
" - Copy"
+
fileName
.
substring
(
fileName
.
indexOf
(
"."
),
fileName
.
length
()));
while
((
a
=
readFile
.
read
())!=-
1
){
writeFile
.
write
(
a
);
}
System
.
out
.
println
(
"Successfully."
);
}
}
else
{
int
a
;
writeFile
=
new
FileWriter
(
outputPath
+
"
\\
"
+
fileName
);
while
((
a
=
readFile
.
read
())!=-
1
){
writeFile
.
write
(
a
);
}
System
.
out
.
println
(
"Successfully."
);
}
}
else
{
System
.
out
.
println
(
"dosen't exists."
);
}
readFile
.
close
();
writeFile
.
close
();
}
}
Back
|
FazBrowse Home
|
New Git URL