on 10-03-2006 11:16 AM
Hi all
i ve created a file in some folder using fileoutput stream(). now i want to delete this file from folder and copy that file into some different folder.
can anyone tell me.How to delete and move a file?
try {
File inputFile = new File("C:\test\fold1\abc.txt");
File outputFile = new File("C:\test\fold2\def.txt");
FileInputStream in = new FileInputStream(inputFile);
FileOutputStream out = new FileOutputStream(outputFile);
FileChannel inc = in.getChannel();
FileChannel outc = out.getChannel();
inc.transferTo(0, inc.size(), outc);
inc.close();
outc.close();
in.close();
out.close();
boolean fileDeleteSuccess = inputFile.delete();
if(!fileDeleteSuccess)
System.out.println("File couldnot be deleted");
else
System.out.println("File deleted!!");
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Try these links.
<u>
http://javaalmanac.com/egs/java.io/CopyFile.html?l=rel</u>;
<u>
http://javaalmanac.com/egs/java.io/DeleteFile.html
</u>
<u>
http://schmidt.devlib.org/java/copy-file.html
</u>
Regards
KK
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi
good
go through this link, i hope these ll help you to solve your problem,
http://help.sap.com/saphelp_nw04s/helpdata/en/dc/f1783fe3263042e10000000a114084/content.htm
thanks
mrutyun^
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
82 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.