Bookmark Topic Watch Topic
  • New Topic

Length of Filenames in java on windows

 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi there

A part of my application needs to rename some files. I have having problems with it when I have longer filenames. It throws me right out of the application without even an exception but gives a windows error.

So I am wondering if there is a maximum length of filename and extension that Java can handle on the windows platform.

Kind regards,
Rachel
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
I would think the limitation is on the OS side. Depending on the filesystem, Windows is limited to 8 characters with a 3 character extension on FAT, 255 characters on VFAT and 256 characters in NTFS. What is the exact error you are receiving and what os are you using?
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Report post to moderator
Hi Joe

I'm using Java 1.4.2 on Windows 2000 Profressional.

Like I sais, I have this code that has to rename Files and I know that it's this code that is causing the problem as everything was fine before that code when in.

What it does is that I have it display that the file is renamed successfully and then save some information to another text file, but about halfway through writing to the file a windows dialog pops up that says "java.exe has caused an error, the application will be terminated" (or something to that effect). The funny thing is that although I know that it's the rename code, the rest of the code in that set to be executed will all get executed before the program is forced to terminate.

So because it was the rename code I thought that my filenames were too long for java, but after trying to rename then to simple a.txt and b.txt I still got the same error.

Cheers,
Rachel
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Report post to moderator
After playing with it for an hour I thought the problem was gone! No such luck, but I did get a chance to write down the exact message.

"java.exe has generated errors and will be closed by Windows. You will need to restart the program. An error log is being created."

Cheers,
Rachel
 
Rachel Swailes
Ranch Hand
Posts: 434
  • Mark post as helpful
  • send pies
  • Report post to moderator
I have done some research on the net and found that this may not be an IO problem at all. I am going to post this on the Intermediate forum with a more detailed header with the information that I have now.
 
Joe Ess
Bartender
Posts: 9362
11
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Here is the follow-up question in the intermediate forum.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!