Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Re: FileDialog Save as Type Problem

Reply
Thread Tools

Re: FileDialog Save as Type Problem

 
 
Andrew Thompson
Guest
Posts: n/a
 
      08-14-2004
On Sat, 14 Aug 2004 13:38:29 GMT, Anony! wrote:

> fd.setFile(fd.getFile() + ".txt");


You should *check* first..

if ( !fd.getFile().toLowerCase().endsWith(".txt") ) {
fd.setFile(fd.getFile() + ".txt");
}

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Reply With Quote
 
 
 
 
Anony!
Guest
Posts: n/a
 
      08-15-2004
> On Sat, 14 Aug 2004 13:38:29 GMT, Anony! wrote:
>
> > fd.setFile(fd.getFile() + ".txt");

>
> You should *check* first..
>
> if ( !fd.getFile().toLowerCase().endsWith(".txt") ) {
> fd.setFile(fd.getFile() + ".txt");
> }


Why do I need to check? I'm writing out to a file, and not the other way
around. So of course, it will end with .txt cos thats what i want.

Thanks

AAA



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.732 / Virus Database: 486 - Release Date: 29/07/2004


 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      08-15-2004
On Sun, 15 Aug 2004 04:12:57 GMT, Anony! wrote:

>> You should *check* first..
>>
>> if ( !fd.getFile().toLowerCase().endsWith(".txt") ) {
>> fd.setFile(fd.getFile() + ".txt");
>> }

>
> Why do I need to check? I'm writing out to a file, and not the other way
> around.


Your file dialog returns a string representing
the file the user selected. If the user selects
'C:\MYFILE.TXT' the above will save it as 'C:\MYFILE.TXT',
whereas no check results in 'C:\MYFILE.TXT.txt'.

HTH

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Reply With Quote
 
Anony!
Guest
Posts: n/a
 
      08-15-2004
> On Sun, 15 Aug 2004 04:12:57 GMT, Anony! wrote:
>
> >> You should *check* first..
> >>
> >> if ( !fd.getFile().toLowerCase().endsWith(".txt") ) {
> >> fd.setFile(fd.getFile() + ".txt");
> >> }

> >
> > Why do I need to check? I'm writing out to a file, and not the other way
> > around.

>
> Your file dialog returns a string representing
> the file the user selected. If the user selects
> 'C:\MYFILE.TXT' the above will save it as 'C:\MYFILE.TXT',
> whereas no check results in 'C:\MYFILE.TXT.txt'.
>
> HTH


good point.

I just assumed that the user would create a new file to save by typing the
file name in the dialog box.

Thanks.

AAA



 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      08-15-2004
On Sun, 15 Aug 2004 08:44:55 GMT, Anony! wrote:

> ..assumed that the user..


The key to disaster.

--
Andrew Thompson
http://www.PhySci.org/ Open-source software suite
http://www.PhySci.org/codes/ Web & IT Help
http://www.1point1C.org/ Science & Technology
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
filedialog for ftp server files Ike Java 2 05-26-2005 07:26 PM
Java 1.4.2 on Mac OS X: FileDialog doesn't work Hans Stoessel Java 2 07-30-2004 12:46 PM
Re: FileDialog window handle Dan Ignatov ASP .Net 0 09-04-2003 09:28 AM
Re: FileDialog window handle Jay B. Harlow [MVP - Outlook] ASP .Net 5 09-03-2003 09:58 AM
wxPython Filedialog question Anand Pillai Python 0 06-27-2003 06:36 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57