Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2006

Tip: Looking for answers? Try searching our database.

file.isFile() returns false on special-character files

Thread view: 
René Schade - 27 Oct 2006 13:22 GMT
Hi,

When running a program in Java 1.3 on AIX file.isFile() returns true on
af file containing special characters (that is Danish characters).

When running the program in Java.1.5 on Linux file.isFile() returns
false??

Does anyone have any kind of experience with this?

Regards,
René
Gordon Beaton - 27 Oct 2006 13:30 GMT
> When running a program in Java 1.3 on AIX file.isFile() returns true
> on af file containing special characters (that is Danish
[quoted text clipped - 4 lines]
>
> Does anyone have any kind of experience with this?

Did you mean to say that the file *name* contains Danish characters?

I'll guess that the character encoding used in your program isn't the
same as that used when you created the file, so the names differ.

Here's a test: create such a file from your Java 1.5 application, then
test with file.isFile(). This should work properly, since the same
encoding will be used in both cases.

The way to fix this is to use the correct locale settings in your
various applications.

/gordon

Signature

[ don't email me support questions or followups ]
g o r d o n  +  n e w s  @  b a l d e r 1 3 . s e

René Schade - 27 Oct 2006 14:08 GMT
> The way to fix this is to use the correct locale settings in your
> various applications.

OK, how do I change the local settings?

BTW I should have said unicode-characters instead of danish characters.

René
Nigel Wade - 27 Oct 2006 17:37 GMT
> Hi,
>
[quoted text clipped - 8 lines]
> Regards,
> René

The contents of the file shouldn't make any difference. Do you mean the filename
contains special characters?

File.isFile() doesn't attempt to open the file or in any way examine the
contents. If File.isFile() is returning false then the file doesn't exist (or
can't be accessed) or it's not a regular file (as determined by the type of the
file, not it's contents). If the file really exists and is a regular file and
you have permission to access it then there is probably something wrong in the
pathname which you have specified, i.e it isn't being understood by Java or the
filesystem.

Can you give us the full pathname, and the permissions to the the file in all
directories on the path?

Signature

Nigel Wade, System Administrator, Space Plasma Physics Group,
           University of Leicester, Leicester, LE1 7RH, UK
E-mail :    nmw@ion.le.ac.uk
Phone :     +44 (0)116 2523548, Fax : +44 (0)116 2523555

René Schade - 27 Oct 2006 18:17 GMT
> File.isFile() doesn't attempt to open the file or in any way examine the
> contents. If File.isFile() is returning false then the file doesn't exist (or
[quoted text clipped - 3 lines]
> pathname which you have specified, i.e it isn't being understood by Java or the
> filesystem.

I have two similar files created by the same system - same permissions
and located in the same folder. The only differende between the two
files is the filename. The first file has the filename "test", here
file.isFile() returns true. The  second file has the name "testæ" (I
don't know if you can see the last character in the filename, but it is
a character used in the danish language and thus UTF-8 character), here
file.isFile() returns false.

On Windows isFile() returns true on both files.

René
Oliver Wong - 27 Oct 2006 21:58 GMT
> I have two similar files created by the same system - same permissions
> and located in the same folder. The only differende between the two
[quoted text clipped - 5 lines]
>
> On Windows isFile() returns true on both files.

   Try specifying the name in your Java code as:

file = new File("test\u00E6");

Or whatever the unicode for the character is.

   If that fails, try testing file.exists() to see if Java can see the file
at all.

   If that fails, try posting an SSCCE
(http://acronyms.thefreedictionary.com/SSCCE) here so that we can spot any
other mistakes that might pop up (I don't expect the SSCCE to be much longer
than 10 lines).

   If that fails, post a bug to Sun.

   - Oliver
René Schade - 28 Oct 2006 16:06 GMT
Oliver Wong skrev:
>     Try specifying the name in your Java code as:
>
[quoted text clipped - 4 lines]
>     If that fails, try testing file.exists() to see if Java can see the file
> at all.

Hi Oliver,

I get acces to the file by calling dir.listfiles() which returns a list
of files.
On each file i the call isFile(), so Java can see the file.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.