Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

too long filename? ? ?

 
 
Peter
Guest
Posts: n/a
 
      03-04-2004
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\\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();
}

All the sub directory is exsit!!!

thanks
from Peter ((E-Mail Removed))
 
Reply With Quote
 
 
 
 
nos
Guest
Posts: n/a
 
      03-04-2004
I would suggest you add this
System.out.println(ee);
and see what the error message is.
--------------------

"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
 
 
 
 
Tony Morris
Guest
Posts: n/a
 
      03-04-2004


"nos" <(E-Mail Removed)> wrote in message
news:vny1c.470991$na.1139603@attbi_s04...
> I would suggest you add this
> System.out.println(ee);
> and see what the error message is.



> --------------------
> > }catch (Exception ee){
> > ee.printStackTrace();
> > }



The stack trace will contain the error message.
You need to show what that message is.

Side note: declaring to catch java.lang.Exception is poor form.

--
Tony Morris
(BInfTech, Cert 3 I.T.)
Software Engineer
(2003 VTR1000F)
Sun Certified Programmer for the Java 2 Platform (1.4)
Sun Certified Developer for the Java 2 Platform


 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      03-04-2004
Peter wrote:

> 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.


There's an OS limit on the length of the filename (255 iirc). I haven't
counted,
but I think your filename is longer than that.

-- chris



 
Reply With Quote
 
Jon A. Cruz
Guest
Posts: n/a
 
      03-04-2004
Chris Uppal wrote:
> Peter wrote:
>
>
>> 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.

>
>
> There's an OS limit on the length of the filename (255 iirc). I haven't
> counted,
> but I think your filename is longer than that.


It depends on the OS and the functions used.

For some MS Windows API calls, prefixing the path will bypass short
limits and allow paths of 32K.



Fun, huh?

 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      03-04-2004
Jon A. Cruz wrote:

> For some MS Windows API calls, prefixing the path will bypass short
> limits and allow paths of 32K.
>
>
>
> Fun, huh?


Oh my, yes. Definitely another winner from Redmond.

-- chris


 
Reply With Quote
 
Mark Thornton
Guest
Posts: n/a
 
      03-04-2004
Jon A. Cruz wrote:
> Chris Uppal wrote:
>
>> Peter wrote:
>>
>>
>>> 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.

>>
>>
>>
>> There's an OS limit on the length of the filename (255 iirc). I haven't
>> counted,
>> but I think your filename is longer than that.

>
>
> It depends on the OS and the functions used.
>
> For some MS Windows API calls, prefixing the path will bypass short
> limits and allow paths of 32K.
>
>


Note that you can't do that from within Java, as Java also parses the
path and objects to the prefix required. There is a bug on the BugParade
with respect to this issue.

http://developer.java.sun.com/develo...s/4403166.html

Only 3 years old ...

Mark Thornton

 
Reply With Quote
 
Peter
Guest
Posts: n/a
 
      03-06-2004
Mark Thornton <(E-Mail Removed)> wrote in message news:<CJM1c.2862$(E-Mail Removed)>...
> Jon A. Cruz wrote:
> > Chris Uppal wrote:
> >
> >> Peter wrote:
> >>
> >>
> >>> 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.
> >>
> >>
> >>
> >> There's an OS limit on the length of the filename (255 iirc). I haven't
> >> counted,
> >> but I think your filename is longer than that.

> >
> >
> > It depends on the OS and the functions used.
> >
> > For some MS Windows API calls, prefixing the path will bypass short
> > limits and allow paths of 32K.
> >
> >

>
> Note that you can't do that from within Java, as Java also parses the
> path and objects to the prefix required. There is a bug on the BugParade
> with respect to this issue.
>
> http://developer.java.sun.com/develo...s/4403166.html
>
> Only 3 years old ...
>
> Mark Thornton


Big problem . Really no way to fix this? I searched the whole
java.sun.com , but still can't find the answer.

thanks for your reply ((E-Mail Removed))
 
Reply With Quote
 
nos
Guest
Posts: n/a
 
      03-06-2004
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
 
Jon A. Cruz
Guest
Posts: n/a
 
      03-06-2004
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.

 
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