This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Greetings! I have .htm page with <input type="file" name="myFile">, my .jsp page uses request.getParameter("myFile");. As a result i get the entire path of the file "C:/blah/blah/blah/blah.gif". How do i go about extracting the file name out of the entire string. Greatly appreciated, m, phx
Cameron Park
Ranch Hand
Joined: Apr 06, 2001
Posts: 371
posted
0
parse it yourself using substring from the last file separator.
Look at the docs for java.io.File (which is a misnomer, because it actually refers to the locations of files, not the files themselves).
Will do it, I think. This is OS-independent, at least for Unix and Windows. Mac File seperators I don't know about.
Customer surveys are for companies who didn't pay proper attention to begin with.
Manjunath Reddy
Ranch Hand
Joined: Jul 26, 2001
Posts: 60
posted
0
File f = new File (request.getParameter("file")); String fileName = f.getName().substring(f.getName().lastIndexOf("/") + 1, f.getName().length()); Just in case you want to take care of unix/ms file seperator problems, you might want to use File.Seperator instead of ("/"). cheers, mpr
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.