Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010
    Posts
    59
    Rep Power
    0

    Cool Checking if a file name already has .txt in it

    I am trying save some text to a file. Originally to save it to text format file I added a .txt to the end of the file name which works fine.

    However, there is a problem because when someone chooses to save over an existing file the file then saves as filename.txt.txt.

    Does anyone know of a good solution? One way is to check the last three characters of the file name for .txt. Is there an easy way to do this?

    Many thanks!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,236
    Rep Power
    19

    Default

    Read the API for String

    db

  3. #3
    Join Date
    Apr 2010
    Posts
    59
    Rep Power
    0

Similar Threads

  1. FileChooser checking for an existing file
    By sky in forum AWT / Swing
    Replies: 4
    Last Post: 12-06-2009, 11:06 PM
  2. checking file extensions
    By gisler in forum New To Java
    Replies: 3
    Last Post: 12-05-2009, 01:25 PM
  3. Checking if file exists in a directory
    By achilles in forum New To Java
    Replies: 7
    Last Post: 08-10-2009, 02:43 AM
  4. reading an Html file and checking for urls
    By sudukrish in forum Advanced Java
    Replies: 1
    Last Post: 04-25-2009, 01:39 AM
  5. Checking of file was modified on the server
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-02-2008, 07:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •