how to save a copy of a file to different location using jfilechooser

hi, this is ravikiran,

In my project there is a situation where when a user clicks on some button, a copy of a file(which is initially in my project folder) must be saved to a location specified by the user.

I have no idea how to do this using JFileChooser.

help me,

thanx in advance

[314 byte] By [raviva] at [2007-11-26 16:02:57]
# 1

JFileChooser lets you choose a file. Once it's done you will have to program the copy function with womething like :

public void copyToDir(String fileSource,String fileDest) {

try {

FileChannel srcChannel = new FileInputStream(fileSource).getChannel();

FileChannel dstChannel = new FileOutputStream(fileDest).getChannel();

dstChannel.transferFrom(srcChannel, 0, srcChannel.size());

srcChannel.close();

dstChannel.force(true);

dstChannel.close();

} catch (IOException e) {

e.printStackTrace();

}

}

ProZa at 2007-7-8 22:24:48 > top of Java-index,Desktop,Core GUI APIs...
# 2
nice
omkara.Javaa at 2007-7-8 22:24:48 > top of Java-index,Desktop,Core GUI APIs...