0

I am trying to create a directory in domino data directory using ssjs that works in all Domino suported OS, like windows and linux etc. I have done the following (not tested)

function getPath(){
  var d = session.getEnvironmentString("directory",true)
  var s = java.io.File.separator
  var path = d + s + "temp"
  var dir:java.io.File = new java.io.File(path);  
  dir.mkdir();
  return path;

}

the returned path is later used to store a file in that directory using java. currently I need to add two backlashes on windows to store the file and not sure how that works in other os and how I can make my function returning the path I need depending on the os used.

var filename = getPath() + "file.txt"
Thomas Adrian
  • 3,543
  • 6
  • 32
  • 62
  • Java is OS independent, so it always creates and uses platform specific separator. Don't worry about two backlashes, it is used only for an escape character if file path is being hardcoded. – JiKra Nov 29 '12 at 20:44

1 Answers1

1

java.io.File.separator returns platform dependent separator.

var filename = getPath() + java.io.File.separator + "file.txt"

http://docs.oracle.com/javase/1.5.0/docs/api/java/io/File.html

Frantisek Kossuth
  • 3,524
  • 2
  • 23
  • 42