Results 1 to 3 of 3
- 04-29-2009, 04:06 PM #1
Member
- Join Date
- Feb 2009
- Posts
- 18
- Rep Power
- 0
dynamically search user input files
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!!
- 04-29-2009, 04:16 PM #2
Use some glue :-)
Use the Scanner class to get the user's file name (if from command prompt) or JOptionPane class if GUI based and then just tack it on to your path:
File namefile = new File("C:\\Worksapce\\myapplication\\" + variable-for-user-input);Chris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 04-29-2009, 04:51 PM #3
Similar Threads
-
how to get input from User
By Alvaro in forum New To JavaReplies: 7Last Post: 01-15-2010, 11:02 PM -
Change data source dynamically while updating web input report
By freezea in forum Reviews / AdvertisingReplies: 0Last Post: 04-17-2009, 02:27 PM -
User input- Pop Up Box
By dedachi in forum AWT / SwingReplies: 3Last Post: 03-23-2009, 04:47 AM -
cant take input from user
By new_1 in forum New To JavaReplies: 6Last Post: 12-25-2007, 07:38 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks