• Post Reply Bookmark Topic Watch Topic
  • New Topic

adding file type

 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is there a way to add a file type to a file retrieved from JFileChooser? Do I have to rename the file and add for example '.png' at the end?
 
Paul Clapham
Sheriff
Posts: 21862
36
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand what you mean by "add a file type to a file". So perhaps you could back up and explain your problem. What exactly is it that you see, where do you see it, and what would you like to see differently?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I will describe it in detail.
A user clicks 'save the image' option. Then JFileChooser pop-ups and he chooses the path and file name. Next, he clicks OK. But the image is saved without extension: 'myimage' unless the user scecify it. I want to add that extension '. png' automtically. There is a simple way to filter files during opening but what about saving?
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there anyone to help?
 
Rob Spoor
Sheriff
Posts: 20817
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After the user pressed OK you can get the file using getSelectedFile(). You can check the file's name, and create a new File object if the extension doesn't match:
 
Lucas Smith
Ranch Hand
Posts: 808
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, I thought about that. thanks anyway :-)

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!