|
Quick Lists
|
|
Bug ID:
|
6222304
|
|
Votes
|
0
|
|
Synopsis
|
REGRESSION: create a file with long file names in Windows XP
|
|
Category
|
java:classes_io
|
|
Reported Against
|
|
|
Release Fixed
|
|
|
State
|
11-Closed, duplicate of 4403166,
bug
|
|
Priority:
|
3-Medium
|
|
Related Bugs
|
|
|
Submit Date
|
27-JAN-2005
|
|
Description
|
FULL PRODUCT VERSION :
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
customer Windows XP [Version 5.1.2600]
A DESCRIPTION OF THE PROBLEM :
I am able to create a file which is invalid in Windows XP. In windows XP, the maximum allowed size for a file name is 255(It includes the absolute path and not just the file name). But Java allows me to create file whose absolute filename length is greater than 255. After the file creation, I can't delete this file in windows(I can't do anything with this file).
Please refer to the following code.
public static void main(String[] args)
{
GenerateFileWithLongName obj = new GenerateFileWithLongName();
obj.generate();
}
public void generate(){
String longFileName;
longFileName = getLongName(220); //Create a name with 220 characters
try{
//System.getProperty("user.dir") = "C:\Documents and Settings\kiran_ms\Desktop" (Length=40(approx))
BufferedWriter br = new BufferedWriter(new FileWriter(new File(System.getProperty("user.dir")+File.separator+longFileName+".txt")));
//So absolute path length is graeter than 255
br.write("first line");
br.flush();
br.close();
System.out.println("Created the file");
}catch(IOException e){
e.printStackTrace();
}
}
private String getLongName(int count){
String name = "";
for (int i=0; i<count; i++){
name += "a";
}
return name;
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Create a java class GenerateFileWithLongName.java
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
public class GenerateFileWithLongName
{
public static void main(String[] args)
{
GenerateFileWithLongName obj = new GenerateFileWithLongName();
obj.generate();
}
public void generate(){
String longFileName;
longFileName = getLongName(220); //Create a name with 220 characters
try{
//System.getProperty("user.dir") = "C:\Documents and Settings\kiran_ms\Desktop" (Length=40(approx))
BufferedWriter br = new BufferedWriter(new FileWriter(new File(System.getProperty("user.dir")+File.separator+longFileName+".txt")));
//So absolute path length is graeter than 255
br.write("first line");
br.flush();
br.close();
System.out.println("Created the file");
}catch(IOException e){
e.printStackTrace();
}
}
private String getLongName(int count){
String name = "";
for (int i=0; i<count; i++){
name += "a";
}
return name;
}
}
2. Save it in a directory whose absolute path length is greater than 35 characters(Eg: "C:\Documents and Settings\kiran_ms\Desktop")
3. Compile and run the program.
4. Now go to "C:\Documents and Settings\kiran_ms\Desktop" and try to delete the file.
5. You can't do anything with this file !!!
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I was expecting an exception thrown when I tried to create the file.
ACTUAL -
File got created, which is an invalid file in Windows XP environment.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
No error message
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.io.IOException;
public class GenerateFileWithLongName
{
public static void main(String[] args)
{
GenerateFileWithLongName obj = new GenerateFileWithLongName();
obj.generate();
}
public void generate(){
String longFileName;
longFileName = getLongName(220); //Create a name with 220 characters
try{
//System.getProperty("user.dir") = "C:\Documents and Settings\kiran_ms\Desktop" (Length=40(approx))
BufferedWriter br = new BufferedWriter(new FileWriter(new File(System.getProperty("user.dir")+File.separator+longFileName+".txt")));
//So absolute path length is graeter than 255
br.write("first line");
br.flush();
br.close();
System.out.println("Created the file");
}catch(IOException e){
e.printStackTrace();
}
}
private String getLongName(int count){
String name = "";
for (int i=0; i<count; i++){
name += "a";
}
return name;
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
None, Except mannually checking for the length(Which will be platform specific)
Release Regression From : 1.4.1_08
The above release value was the last known release where this
bug was known to work. Since then there has been a regression.
xxxxx@xxxxx 2005-1-27 13:12:19 GMT
|
|
Work Around
|
N/A
|
|
Evaluation
|
duplicate of 4403166. the fact that we partically support long filepath on
windows in 1.4.x ("partically" means that some apis do, some apis don't) causes
confusion. With the fix of 4403166, now long filepath (longer than 260, but
each component of the path still has the 260 limit) is fully supported by
java.io.File class on nt based windows platforms .
xxxxx@xxxxx 2005-2-04 07:59:28 GMT
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |