Here is what I wanna do: 

1. Check if a folder exists
2. If it does not exists, create the folder
3. If it doest exists do nothing
4. At last create a file in that folder

Everything is working fine in Windows 7, but when I run the application in Ubuntu it doesn't create the folder, it is just creating the file with the folder name, example: (my file name is xxx.xml and the folder is d:\temp, so in Ubuntu the file is generated at d: with the name temp\xxx.xml). Here is my code:

```
File folder = new File("D:\\temp");
if (folder.exists() && folder.isDirectory()) {
} else {
    folder.mkdir();
}

String filePath = folder + File.separator;
File file = new File(filePath + "xxx.xml");

StreamResult result = new StreamResult(file);
transformer.transform(source, result);
// more code here 

```
['https://Stackoverflow.com/questions/20066413', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1966049/']
Linux does not use drive letters (like D:) and uses forward slashes as file separator.

You can do something like this:

```
File folder = new File("/path/name/of/the/folder");
folder.mkdirs(); // this will also create parent directories if necessary
File file = new File(folder, "filename");
StreamResult result = new StreamResult(file);

```
On Unix-like systems no logical discs. You can try create on `/tmp` or `/home`
Below code for create `temp` dirrectory in your home directory:

```
String myPathCandidate = System.getProperty("os.name").equals("Linux")? System.getProperty("user.home"):"D:\\";
  System.out.println(myPathCandidate);
  //Check write permissions
  File folder = new File(myPathCandidate);
  if (folder.exists() && folder.isDirectory() && folder.canWrite()) {
      System.out.println("Create directory here");
  } else {System.out.println("Wrong path");}

```

or, for `/tmp` - system temp dicecrory. Majority of users can write here:

```
String myPathCandidate = System.getProperty("os.name").equals("Linux")? System.getProperty("java.io.tmpdir"):"D:\\";

```