JFileChooser, after file selected...

T

tiewknvc9

What I would like to do, is SAVE a file over an old file!

I have been able to create new files without a problem, however when I
select an already created file such as "test.avi" that I want to write
over, I cannot delete the file in order to replace it with the new
file.

Ive checked canwrite() - and it returns false from the

(new File(MyJFileChooser.getname)()).canwrite() function.

Im stuck, seems like a simple problem though.... right?!
 
R

Richard Huddleston

You're not getting the correct file.

You want to do something like

int result = jFileChooser.showSaveDialog()

if (result == JFileChooser.OK_OPTION)
{
File file = jFileChooser.getSelectedFile()

//do work with file
}

you're getting the name of the selected file .. and then creating a file
which points to your user directory with the given name.
 
T

tiewknvc9

thank you.

I was accessing the file directly through jfilchooser, that is why i
could not delete it....
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,591
Members
45,102
Latest member
GregoryGri
Top