How to move one file (eg. .txt or .jpg) to one particular folder in Java? I want line by line explanation. I know InputStream
and OutputStream
read from InputStream
and write to OutputStream
. But how do they take bytes etc.? Any ideas?
Asked
Active
Viewed 1,080 times
0

user7116
- 63,008
- 17
- 141
- 172

tejas26389
- 73
- 1
- 1
- 8
-
2google ( not stackoverflow ) is your friend. – Kal May 12 '11 at 15:23
-
I don't want to try myself but I want you to do it with line by line explanation. – Jan Zyka May 12 '11 at 15:34
-
you are telling us to do your homework! won't help in exams! ;) – Bhushan May 12 '11 at 15:36
-
Duplicate: http://stackoverflow.com/questions/300559/move-copy-file-operations-in-java – GreenMatt May 12 '11 at 15:47
1 Answers
3
You wouldn't do it by reading/writing the contents of the file. Look at the File Javadoc. You can use the File
class to rename and move individual files at a file level -- without having to access the contents of the files. In particular, see the renameTo
and mkdirs
methods of File
.

QuantumMechanic
- 13,795
- 4
- 45
- 66