Discuss (FTP) and (SFTP, FTPS and SCP), our Java file transfer clients.

Other language support

no avatar
User

firewallindia

Posts

11

Joined

Mon Jun 06, 2011 11:12 pm

Other language support

by firewallindia » Mon Jun 06, 2011 11:43 pm

Hi guys,

chinese or japnese characters file names are listed with question mark. This happens only in windows. I'm using "utf-8" encoding.

sample:
FtpClient fc =new FtpClient();
fc.setCharacterEncoding("utf-8");
String[] arr=fc.dir();
for(int i=0;i<arr.length;i++)
{

System.out.println(arr[i]);
}

This code works good for linux. I tried with GBK and GB232 encoding too. Kindly help :(
using free version
no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

Re: Other language support

by support2 » Tue Jun 07, 2011 9:21 am

no avatar
User

firewallindia

Posts

11

Joined

Mon Jun 06, 2011 11:12 pm

by firewallindia » Tue Jun 07, 2011 3:17 pm

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Tue Jun 07, 2011 3:52 pm

no avatar
User

firewallindia

Posts

11

Joined

Mon Jun 06, 2011 11:12 pm

by firewallindia » Tue Jun 07, 2011 4:15 pm

no avatar
User

firewallindia

Posts

11

Joined

Mon Jun 06, 2011 11:12 pm

by firewallindia » Tue Jun 07, 2011 9:27 pm

no avatar
User

support2

Posts

3987

Joined

Tue May 18, 2004 8:30 am

by support2 » Wed Jun 08, 2011 8:50 am

no avatar
User

firewallindia

Posts

11

Joined

Mon Jun 06, 2011 11:12 pm

posted the code

by firewallindia » Wed Jun 08, 2011 3:31 pm

import com.enterprisedt.net.ftp.FTPTransferType;
import com.enterprisedt.net.ftp.FTPConnectMode;
import com.enterprisedt.net.ftp.FTPMessageListener;
import com.enterprisedt.net.ftp.*;
import com.enterprisedt.net.ftp.FTPFile;
import java.util.logging.*;
import java.util.*;
class FTPmine
{ private static final Logger LOGGER = Logger.getLogger(FTPmine.class.getName());
//Logger
private static Logger log = Logger.getLogger(FTPmine.class.getName());
public static void main(String args[])
{
try
{
FTPmine fu=new FTPmine();
FTPClient fc=null;
if(args[0].equals("1"))
{
fc=fu.getFTPClient("felog-w2k8","viswesh","viswesh");
}
String[] arr=fc.dir();
System.out.println("-->"+fc.getControlEncoding()+fc.pwd());

for(int i=0;i<arr.length;i++)
{

System.out.println(arr[i]);
}
}
catch(Exception e)
{
e.printStackTrace();
}
}

public static FTPClient getFTPClient(String hostName, String userName, String password)
throws Exception {
log.info("Connecting");
try {
FTPClient ftp = new FTPClient();
if(!ftp.connected())
{
ftp.setControlEncoding("utf-8");
System.out.println("encoding set da");
ftp.setRemoteHost(hostName);
ftp.connect();
}
else
{
System.out.println("encoding notset");
}
LOGGER.log(Level.FINER," FTP client {0}",ftp);
FTPMessageCollector listener = new FTPMessageCollector();
ftp.setMessageListener(listener);
loginFTPClient(userName, password,ftp);
// set up passive ASCII transfers
log.info("Setting up Active, BINARY transfers");
ftp.setConnectMode(FTPConnectMode.ACTIVE);
ftp.setType(FTPTransferType.BINARY);
return ftp;
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
private static void loginFTPClient(String user, String password,FTPClient ftp)
throws Exception {
// login
log.info("Logging in");
ftp.login(user, password);
}

}
no avatar
User

firewallindia

Posts

11

Joined

Mon Jun 06, 2011 11:12 pm

by firewallindia » Wed Jun 08, 2011 10:20 pm

anythin wrong in the code?? should i have to try some other method?
no avatar
User

firewallindia

Posts

11

Joined

Mon Jun 06, 2011 11:12 pm

by firewallindia » Thu Jun 09, 2011 8:54 pm


Who is online

Users browsing this forum: No registered users and 126 guests

Powered by phpBB ® | phpBB3 Style by KomiDesign
cron