Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By jim829

Thread: Autoselect perticular file from provided location in the code

  1. #1
    dmk.3678 is offline Member
    Join Date
    Jun 2015
    Posts
    8
    Rep Power
    0

    Default Autoselect perticular file from provided location in the code

    Hi, Can someone please help me on below scenario.

    I have a file (for Example: test.xls or say *.xls) at location lets say at "E:\New Folder\Java Swing\".
    No i want the code to pickup this test.xls form above location automatically so i don't have to popup a file chooser and manually go that location and select this file.

    Can some one please help on this ?

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Autoselect perticular file from provided location in the code

    The JFileChooser returns a File object of the selected file. You can create your own file object by using the File class with the string you mentioned above including the file name. Backslashes need to be doubled to be parsed correctly. Note, file globs won't work like that. You have to specify a particular file. Or you could specify a file filter or directory to get particular files. Read the File class documentation to see what options you have.

    Regards,
    Jim
    dmk.3678 likes this.
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    Gotcha is offline Member
    Join Date
    Jun 2015
    Location
    America
    Posts
    29
    Rep Power
    0

    Default Re: Autoselect perticular file from provided location in the code

    Have you loaded in an example to see how things work? How about this one?
    Gets the content from a File as String Array List : Text Read Write¬*¬ę¬*File Input Output¬*¬ę¬*Java

Similar Threads

  1. code to upload a pdf file to specific location on server
    By srinivasa rao in forum New To Java
    Replies: 8
    Last Post: 09-08-2011, 12:30 PM
  2. Class inheritance question (code provided)
    By Adomini in forum New To Java
    Replies: 8
    Last Post: 10-09-2010, 05:30 AM
  3. Replies: 8
    Last Post: 05-15-2010, 04:05 PM
  4. Replies: 3
    Last Post: 05-06-2010, 07:10 AM
  5. Replies: 3
    Last Post: 01-11-2010, 06:48 AM

Posting Permissions

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