Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > too long filename? ? ?

Reply
Thread Tools

too long filename? ? ?

 
 
Mark Thornton
Guest
Posts: n/a
 
      03-06-2004
nos wrote:
> My book says that the constructor can only throw
> "FileNotFoundException"
> The comments in the source file for this constructor say
> ---
> * @exception FileNotFoundException if the file exists but is a directory
> * rather than a regular file, does not exist but cannot
> * be created, or cannot be opened for any other reason
> * @exception SecurityException if a security manager exists and its
> * <code>checkWrite</code> method denies write access
> * to the file.
> ---
> There is no exception for filename too long!
> So now will you tell us what the error message actually says?
>


FileNotFoundException is what happens when you attempt to open a file
with a long path name.

 
Reply With Quote
 
 
 
 
Mark Thornton
Guest
Posts: n/a
 
      03-06-2004
Jon A. Cruz wrote:

> Peter wrote:
>
>> try{
>> FileOutputStream f = new
>> FileOutputStream("projects\\os\\2004_03_04_JBuilde rX\\2004_03_04_extras\\2004_03_04_BorlandXML\\2004 _03_04_doc\\2004_03_04_api-doc\\2004_03_04_com\\2004_03_04_borland\\2004_03_0 4_xml\\2004_03_04_service\\2004_03_04_simpledb\\20 04_03_04_jxinfo\\2004_03_04_ColumnName.html");
>>
>> }catch (Exception ee){
>> ee.printStackTrace();
>> }

>
>
> Have you tried building that up a single File object at a time?
>
>
> File dirOne = new File("projects");
> File dirTwo = new File( dirOne, "os" );
> ...
> ?
>
>
> Not sure if that would help in this case, but it would keep your Java
> code portable among other things.
>


It doesn't help. Windows requires a special syntax where the path
exceeds 260 characters and Java does not support this. For such paths
you either do all your I/O using JNI or perhaps use JNI to find the
short versions of the names and thus possibly construct an equivalent
path which fits within the 260 character limit. It is quite common for
Windows programs written in other languages to fail with these paths,
and of course Windows 9X doesn't support long paths at all. Hopefully
when eventually this bug is fixed we will have a nice consistent
interface that works for all path lengths (unlike the underlying Win32 API).

Mark Thornton
(The author of the relevant bug report)

 
Reply With Quote
 
 
 
 
nos
Guest
Posts: n/a
 
      03-07-2004
Stupid me. here is from MS Visual C++
#ifndef _MAC
#define _MAX_PATH 260 /* max. length of full pathname */
#define _MAX_DRIVE 3 /* max. length of drive component */
#define _MAX_DIR 256 /* max. length of path component */
#define _MAX_FNAME 256 /* max. length of file name component */
#define _MAX_EXT 256 /* max. length of extension component */
#else /* def _MAC */
#define _MAX_PATH 256 /* max. length of full pathname */
#define _MAX_DIR 32 /* max. length of path component */
#define _MAX_FNAME 64 /* max. length of file name component */
#endif /* _MAC */


"nos" <(E-Mail Removed)> wrote in message
news:ctc2c.124868$4o.164679@attbi_s52...
> My book says that the constructor can only throw
> "FileNotFoundException"
> The comments in the source file for this constructor say
> ---
> * @exception FileNotFoundException if the file exists but is a directory
> * rather than a regular file, does not exist but cannot
> * be created, or cannot be opened for any other reason
> * @exception SecurityException if a security manager exists and its
> * <code>checkWrite</code> method denies write access
> * to the file.
> ---
> There is no exception for filename too long!
> So now will you tell us what the error message actually says?
>
>
> "Peter" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) om...
> > Hi
> > If i do the following, it will throw exception because the filename
> > is too long. How to fix it? I am using JBuilder X, JDK 1.4.2 and
> > windows XP.
> >
> > try{
> > FileOutputStream f = new
> >

>

FileOutputStream("projects\\os\\2004_03_04_JBuilde rX\\2004_03_04_extras\\200
>

4_03_04_BorlandXML\\2004_03_04_doc\\2004_03_04_api-doc\\2004_03_04_com\\2004
>

_03_04_borland\\2004_03_04_xml\\2004_03_04_service \\2004_03_04_simpledb\\200
> 4_03_04_jxinfo\\2004_03_04_ColumnName.html");
> > }catch (Exception ee){
> > ee.printStackTrace();
> > }
> >
> > All the sub directory is exsit!!!
> >
> > thanks
> > from Peter ((E-Mail Removed))

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having compilation error: no match for call to (const __gnu_cxx::hash<long long int>) (const long long int&) veryhotsausage C++ 1 07-04-2008 05:41 PM
Allow Roles name too long?? AD groups too long? Integrated Security wildman@noclient.net ASP .Net 0 03-10-2008 03:47 PM
CDOSYS executes but takes TOO TOO long? JVRudnick ASP General 13 02-28-2008 03:03 PM
UPDATE (was: How long is too long) Mark C Digital Photography 0 07-28-2003 12:56 PM
how long is too long? Mark C Digital Photography 12 07-25-2003 04:53 PM



Advertisments