[jira] Created: (NET-240) FTPClient can't support Chinese or Japanese language in listFiles()

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jira] Created: (NET-240) FTPClient can't support Chinese or Japanese language in listFiles()

Gary D. Gregory (Jira)
FTPClient can't support Chinese or Japanese language in listFiles()
-------------------------------------------------------------------

                 Key: NET-240
                 URL: https://issues.apache.org/jira/browse/NET-240
             Project: Commons Net
          Issue Type: Bug
    Affects Versions: 2.0
         Environment: Both Win and Linux,  jdk1.5 or jdk1.6
            Reporter: Eisen Wang
            Priority: Critical


while coding as below:
FTPClient ftp = new FTPClient();
int reply;

ftp.connect("10.110.13.18",2001);

ftp.login("user","password");
//  ... // transfer files
ftp.type(FTPClient.ASCII_FILE_TYPE);

FTPFile[] temp = ftp.listFiles();
System.out.println(temp.length);
for (int i = 0; i < temp.length; i++)
{
        System.out.println(temp[i].getName());
}; //filtered all the files

if the remote ftp server has a Chinese or Japanese file, then it would print a massive text on screen.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Updated: (NET-240) FTPClient can't support Chinese or Japanese language in listFiles()

Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/NET-240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rory Winston updated NET-240:
-----------------------------

    Priority: Major  (was: Critical)

> FTPClient can't support Chinese or Japanese language in listFiles()
> -------------------------------------------------------------------
>
>                 Key: NET-240
>                 URL: https://issues.apache.org/jira/browse/NET-240
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 2.0
>         Environment: Both Win and Linux,  jdk1.5 or jdk1.6
>            Reporter: Eisen Wang
>
> while coding as below:
> FTPClient ftp = new FTPClient();
> int reply;
> ftp.connect("10.110.13.18",2001);
> ftp.login("user","password");
> //  ... // transfer files
> ftp.type(FTPClient.ASCII_FILE_TYPE);
> FTPFile[] temp = ftp.listFiles();
> System.out.println(temp.length);
> for (int i = 0; i < temp.length; i++)
> {
> System.out.println(temp[i].getName());
> }; //filtered all the files
> if the remote ftp server has a Chinese or Japanese file, then it would print a massive text on screen.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Commented: (NET-240) FTPClient can't support Chinese or Japanese language in listFiles()

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

    [ https://issues.apache.org/jira/browse/NET-240?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12842639#action_12842639 ]

Rory Winston commented on NET-240:
----------------------------------

This should work as long as the control encoding is set appropriately.

Remember that the printstream encoding and txt encoding for your ide/terminal must also be set. Tthe following works for me:

{code:java}      
       FTPClient client = new FTPClient();
       client.setControlEncoding("utf-8");
       client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out)));
       client.connect("localhost");
       client.login("user", "pass");
       
       PrintStream out = new PrintStream(System.out, true, "utf-8");

       for (FTPFile file  : client.listFiles())
      out.println(file.getName());
       
       
       out.println("你好吗"); // this filename was printed in the test above
{code}

> FTPClient can't support Chinese or Japanese language in listFiles()
> -------------------------------------------------------------------
>
>                 Key: NET-240
>                 URL: https://issues.apache.org/jira/browse/NET-240
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 2.0
>         Environment: Both Win and Linux,  jdk1.5 or jdk1.6
>            Reporter: Eisen Wang
>
> while coding as below:
> FTPClient ftp = new FTPClient();
> int reply;
> ftp.connect("10.110.13.18",2001);
> ftp.login("user","password");
> //  ... // transfer files
> ftp.type(FTPClient.ASCII_FILE_TYPE);
> FTPFile[] temp = ftp.listFiles();
> System.out.println(temp.length);
> for (int i = 0; i < temp.length; i++)
> {
> System.out.println(temp[i].getName());
> }; //filtered all the files
> if the remote ftp server has a Chinese or Japanese file, then it would print a massive text on screen.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply | Threaded
Open this post in threaded view
|

[jira] Closed: (NET-240) FTPClient can't support Chinese or Japanese language in listFiles()

Gary D. Gregory (Jira)
In reply to this post by Gary D. Gregory (Jira)

     [ https://issues.apache.org/jira/browse/NET-240?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Rory Winston closed NET-240.
----------------------------

    Resolution: Not A Problem

> FTPClient can't support Chinese or Japanese language in listFiles()
> -------------------------------------------------------------------
>
>                 Key: NET-240
>                 URL: https://issues.apache.org/jira/browse/NET-240
>             Project: Commons Net
>          Issue Type: Bug
>    Affects Versions: 2.0
>         Environment: Both Win and Linux,  jdk1.5 or jdk1.6
>            Reporter: Eisen Wang
>
> while coding as below:
> FTPClient ftp = new FTPClient();
> int reply;
> ftp.connect("10.110.13.18",2001);
> ftp.login("user","password");
> //  ... // transfer files
> ftp.type(FTPClient.ASCII_FILE_TYPE);
> FTPFile[] temp = ftp.listFiles();
> System.out.println(temp.length);
> for (int i = 0; i < temp.length; i++)
> {
> System.out.println(temp[i].getName());
> }; //filtered all the files
> if the remote ftp server has a Chinese or Japanese file, then it would print a massive text on screen.

--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.