how to read a file with non-ascii file name

Discussion in 'Java' started by guava, Jul 8, 2003.

  1. guava

    guava Guest

    Hi,

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

    I have some code like the following:
    ***************************************************************
    import java.io.*;

    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.length();
    byte[] buf = new byte[len];
    DataInputStream in = new DataInputStream(new
    FileInputStream(list)));
    in.readFully(buf);
    FileOutputStream out = new FileOutputStream(new File(dest,
    list.getName()));
    out.write(buf);
    out.flush();
    in.close();
    out.close();
    }
    }
    }

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

    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.
     
    guava, Jul 8, 2003
    #1
    1. Advertising

  2. guava

    Roedy Green Guest

    On 7 Jul 2003 19:40:39 -0700, (guava) wrote or
    quoted :

    >FileOutputStream out = new FileOutputStream(new File(dest,
    >list.getName()));


    you had better close the input first.

    See http://mindprod.com/jgloss/file.html 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 http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
     
    Roedy Green, Jul 8, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. TOXiC
    Replies:
    5
    Views:
    1,259
    TOXiC
    Jan 31, 2007
  2. Ming en Chia
    Replies:
    1
    Views:
    93
    Rodrigo Bermejo
    Mar 13, 2008
  3. Jochen Lehmeier

    DBD::Oracle, Unicode, non-UTF8-non-ASCII strings

    Jochen Lehmeier, Jul 23, 2009, in forum: Perl Misc
    Replies:
    0
    Views:
    411
    Jochen Lehmeier
    Jul 23, 2009
  4. bruce
    Replies:
    38
    Views:
    277
    Mark Lawrence
    Nov 1, 2013
  5. MRAB
    Replies:
    0
    Views:
    98
Loading...

Share This Page