Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

creating directory name for file upload

 
elicia dent
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic