Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > how to read a file with non-ascii file name

Thread Tools

how to read a file with non-ascii file name

Posts: n/a

Does anyone know how to open a FileInputStream on a file with
non-ascii file name?

I have some code like the following:
************************************************** *************

public class CopyFile
public static void main(String[] args)
throws IOException
File src = new File(args[0]);
File dest = new File(args[1]);

File[] list = src.listFiles();
for ( int i = 0; i < list.length; i++ )
int len = (int) list[i].length();
byte[] buf = new byte[len];
DataInputStream in = new DataInputStream(new
FileOutputStream out = new FileOutputStream(new File(dest,

************************************************** **

My problem is that I will get a FileNotFoundException when I tried to
open the FileInputStream on a filename with non-ascii characters.

Thanks for any help.
Reply With Quote
Roedy Green
Posts: n/a
On 7 Jul 2003 19:40:39 -0700, Removed) (guava) wrote or
quoted :

>FileOutputStream out = new FileOutputStream(new File(dest,

you had better close the input first.

See to see how to display the
canonical names of your in and out file. You may be surprised.

Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See for The Java Glossary.
Reply With Quote

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
adding a variable name to a hash to name is part of the variable name Bobby Chamness Perl 2 04-22-2007 09:54 PM
print("my name is {name}, and {age}-year old {gender}", name, age, gender); =?iso-8859-1?B?bW9vcJk=?= Java 7 01-02-2006 04:39 PM
Read form "name" attribute when it contains form field with name "name" Pavils Jurjans Javascript 3 03-18-2005 01:39 PM
name = name.substring(0, name.lastIndexOf('.')); Help please Jack-2 Javascript 3 12-24-2003 04:39 PM
Re: Urgent! how to get object name, method name and attribute name based on the strings? ding feng C++ 2 06-25-2003 01:18 PM