1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

dynamically search user input files

Discussion in 'Java' started by Juuno, Apr 29, 2009.

  1. Juuno

    Juuno New Member

    Joined:
    Feb 3, 2009
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    When we want to open a file from java program, we use the following syntax.
    File namefile = new File ("file-path\\file-name");
    eg. File namefile = new File("C:\\Workspace\\myapplication\\mydata.xml")

    But instead of that 'mydata.xml', i would like to get the file name from the user input and accept it with variable and then I will search it whether it exists in the folder I specified, in that case, I know the location except the file name coz the user will input it.

    File namefile = new File("C:\\Worksapce\\myapplication\\variable-for-user-input")

    how can I do this?

    Thanks in advance!!
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,276
    Likes Received:
    364
    Trophy Points:
    83
    Use StringBuffer to get the final string
     

Share This Page