dynamically search user input files

Juuno's Avatar, Join Date: Feb 2009
Go4Expert Member
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!!
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Use StringBuffer to get the final string