File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes creating directory name for file upload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "creating directory name for file upload" Watch "creating directory name for file upload" New topic
Author

creating directory name for file upload

elicia dent
Greenhorn

Joined: Jul 13, 2009
Posts: 9
Hello All
Please , what is the syntax to create a filename that includes a variable, i.e.,

var orgName = "Staples";
String fileDir = "/tmp" + orgName;
File saveTo = new File(fDir, fileName);

Obviously, the first line doesn't work, but I can't figure out how to do it for some reason.

Many thanks
Elicia
Zandis Murāns
Ranch Hand

Joined: Aug 18, 2009
Posts: 174



In all cases you should better user System.getProperty("java.io.tmpdir") instead of static temp directory names and File.separator instead of directory separator chars (slashes and backslashes).

File saveTo = new File(fDir, fileName); This will create file (directory) object, but not real directory on your hard drive. Use saveTo.mkdirs() to actually create directory.
elicia dent
Greenhorn

Joined: Jul 13, 2009
Posts: 9
Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: creating directory name for file upload