title: What are possible reasons for java.io.IOException: "The filename, directory name, or volume label syntax is incorrect"
body: <p>I am trying to copy a file using the following code:</p>
  
  <pre><code>File targetFile = new File(targetPath + File.separator + filename);
  ...
  targetFile.createNewFile();
  fileInputStream = new FileInputStream(fileToCopy);
  fileOutputStream = new FileOutputStream(targetFile);
  byte[] buffer = new byte[64*1024];
  int i = 0;
  while((i = fileInputStream.read(buffer)) != -1) {
      fileOutputStream.write(buffer, 0, i);
  }
  </code></pre>
  
  <p>For some users the <code>targetFile.createNewFile</code> results in this exception:</p>
  
  <pre><code>java.io.IOException: The filename, directory name, or volume label syntax is incorrect
      at java.io.WinNTFileSystem.createFileExclusively(Native Method)
      at java.io.File.createNewFile(File.java:850)
  </code></pre>
  
  <p>Filename and directory name seem to be correct. The directory <code>targetPath</code> is even checked for existence before the copy code is executed and the filename looks like this: <code>AB_timestamp.xml</code></p>
  
  <p>The user has write permissions to the <code>targetPath</code> and can copy the file without problems using the OS.</p>
  
  <p>As I don't have access to a machine this happens on yet and can't reproduce the problem on my own machine I turn to you for hints on the reason for this exception.</p>