Java io IOException The filename, directory name, or volume label syntax is incorrect

I am trying to copy a file using the following 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); }

For some users the targetFile.createNewFile results in this exception:

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)

Filename and directory name seem to be correct. The directory targetPath is even checked for existence before the copy code is executed and the filename looks like this: AB_timestamp.xml

The user has write permissions to the targetPath and can copy the file without problems using the OS.

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…

Ads

Related Tutorials/Questions & Answers:

how to resolve this JDBC Error?
how to resolve this JDBC Error?  i am trying to Exceute this code: import java.sql.DatabaseMetaData; import java.sql.Connection; import... but when i am executing this code i am getting this Error: Exception in thread

Advertisements

error occured in following page ... how to resolve it?
error occured in following page ... how to resolve it?  // to convert... error ....wht i shud do???????? i m java beginner so plz explain in smooth way.... error is:::: Exception in thread "main" java.lang.IllegalArgumentException

how to display the value of termcell name in label
how to display the value of termcell name in label  want to display the tercell name in label report of pending apllication of termcellname code of the jsp page is as: <%@ taglib uri="http://displaytag.sf.net" prefix

Java get Filename without Extension
Java get Filename without Extension       In this section, you will learn how to obtain the filename without extension. For this, the file name or the directory name

Determining if a Filename path is a file or a directory
Determining if a Filename path is a file or a directory.... What you need to do, just create a File object and pass some file name or a directory in it. We are using a following methods to solve this problem

Why do the slashes change when the console gives me the error?
:\www.queen.com\website\screenshots\amit1220120625_110414.PNG (The filename, directory name, or volume label syntax is incorrect) at java.io.RandomAccessFile.open...Why do the slashes change when the console gives me the error?   

ModuleNotFoundError: No module named 'pkgutil_resolve_name'
: No module named 'pkgutil_resolve_name' How to remove the ModuleNotFoundError: No module named 'pkgutil_resolve_name' error? Thanks   Hi..., ModuleNotFoundError: No module named 'pkgutil_resolve_name' error

How to Checking Syntax Error in PHP from Command Line
How to Checking Syntax Error in PHP from Command Line  Checking Syntax Error in PHP from Command Line   PHP allows you to check your script.... It will check the syntax error in your script and show the �??Unexpected token �

How to store url path in file ?
\screenshots\amit1220120625_104252.PNG (The filename, directory name, or volume label syntax is incorrect) at java.io.RandomAccessFile.open(Native Method...How to store url path in file ?  Hi, How to store url path in file

sql syntax error help
sql syntax error help  this query show syntax error .. i am unable to figure it out insert into order (orderdate, dpname, paymethod, tamount...') where is the error ?   Please send the error details and the datatype

ERROR 601 (42P00): Syntax error. Encountered
ERROR 601 (42P00): Syntax error. Encountered   Hi, In HBase program I am executing the insert into query, but it is giving following error: ERROR 601 (42P00): Syntax error. Encountered "insert" at line 1, column 1. How

parser error xmlparseentityref no name
parser error xmlparseentityref no name  While parsing the error in my mobile application ..i'm getting the following error.. "parser error xmlparseentityref no name" and that is because of "&". I have also tried the "&

How to store url path?
\amit1220120625_110414.PNG (The filename, directory name, or volume label syntax is incorrect...How to store url path?  Image is stored in physical directory like...() + ".PNG"; this physical directory is working fine but I want store in url

Syntax error in my UPDATE..please advise
Syntax error in my UPDATE..please advise  Hi experts, I tested my code and NetBean IDE gave me the following message:- You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version

How to get filename in JTextArea in following case?
How to get filename in JTextArea in following case?  Hi, i'm... java.awt.*; import javax.swing.*; import java.awt.event.*; class FileName extends... pane; FileName(){ setLayout(null); JTextAreaOutputDirectory=new

runtime error:Invalid column name
runtime error:Invalid column name  Hello, Can anyone please help me on this query? Programatically it is showing run time error. But in sql query...; } } Console Output: Getting Results! java.sql.SQLException: Invalid column name

How to set Marathi font to Label??
How to set Marathi font to Label??  Hello, I am doing one project in java-Swing Farm Management i want to set Marathi label in that so how i can? plzzzz help me its urgent

Can anybody tell me how to resolve this issue?
Can anybody tell me how to resolve this issue?  java.lang.Exception: Exception : java.lang.Exception: Generic Errors = java.util.MissingResourceException: Can't find bundle for base name Connection, locale en_US

How to find MySQL data directory name?
How to find MySQL data directory name? There are various ways to find the data...; directory of Windows 7 computer. Here is the video tutorial of: "How to find MySQL data directory name?" Method 2: Connect to mysql command line

How do I resolve this Java Class not found exception?
How do I resolve this Java Class not found exception?  Hi, Many time new developer faces the Class not found exception. Why it happens and how to resolve this? Thanks   Hi, The main reason of this exception is un

data type used to store name.(getting an error)
data type used to store name.(getting an error)    Statement stm... getting an error like dis: "ename cannot be resolved to a variable" whats the problem in my code and how to rectify it. plzz help n thanx in adv

uploading a file at another system in lan using jsp
://hpws1/sharedmxd/pdf/" it gave an error message " http:\hpws1\sharedmxd\pdf\EAIMConcepts.pdf (The filename, directory name, or volume label syntax is incorrect)" How can i resolve that error??? Thanks in advance

uploading a file
",then it is giving the following error message "http://192.168.12.5:8080/tomcat-docs/myapps (The filename, directory name, or volume label syntax is incorrect)".what could be the reason for this error and how can i resolve this? Thanks

Error: /usr/sbin/ifconfig: No such file or directory
Error: /usr/sbin/ifconfig: No such file or directory  HI, I am trying to run the some setup and it throws the error: Error: /usr/sbin/ifconfig: No such file or directory How to solve this? Thanks   HI, this error

How to design a music system volume button
How to design a music system volume button In this tutorial we are going to tell you how to design a music system volume button. Let's go with this example. We start here: Make a New File: Make a new file

error
/ServletUserEnquiryForm.shtml getting an error given below SQLException caught: [Microsoft][ODBC SQL Server Driver]COUNT field incorrect or syntax error please suggest

how to read files of directory objective c
how to read files of directory objective c  how to read files of directory in objective c?   [[NSFileManager defaultManager] contentsOfDirectoryAtPath:bundleRoot error:nil]   To read the text file using

What is Java IO FileNotFoundException?

java.io.FileNotFoundException. Signals that an attempt to open the file denoted by a specified pathname has failed. This exception will be thrown by the FileInputStream , FileOutputStream , and RandomAccessFile constructors when a file with the specified pathname does not exist.