How to move a file using Java [closed]
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?
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
.
精彩评论