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

  • Thread starter =?iso-8859-1?B?UmVu6SBTY2hhZGU=?=
  • Start date
?

=?iso-8859-1?B?UmVu6SBTY2hhZGU=?=

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é
 
G

Gordon Beaton

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?

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
 
?

=?iso-8859-1?B?UmVu6SBTY2hhZGU=?=

Gordon said:
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é
 
N

Nigel Wade

René Schade said:
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é

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

=?iso-8859-1?B?UmVu6SBTY2hhZGU=?=

Nigel said:
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.

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é
 
O

Oliver Wong

René Schade said:
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.

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
 
?

=?iso-8859-1?B?UmVu6SBTY2hhZGU=?=

Oliver Wong skrev:
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.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top