Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
7k views
in Java FTP by
Hello,

I'm trying to send a text file from a Linux machine to a Windows machine. Since it is a text file, I want to use ASCII mode so the line numbers get changed properly. The problem is that this file has high-byte characters in ISO-8859-1 format, but the "put" method reads the file using a UTF-8 InputStreamReader. As soon as it hits a high-byte character, it dies:

sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java(Compiled Code))
at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java(Inlined Compiled Code))
at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java(Compiled Code))
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java(Compiled Code))
at java.io.InputStreamReader.read(InputStreamReader.java(Compiled Code))
at java.io.BufferedReader.fill(BufferedReader.java(Compiled Code))
at java.io.BufferedReader.readLine(BufferedReader.java(Compiled Code))
at java.io.LineNumberReader.readLine(LineNumberReader.java(Compiled Code))
at com.enterprisedt.net.ftp.FTPClient.putASCII(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.put(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.put(Unknown Source)

Is there some way I can instruct the ftp client to read the file with a given encoding?

Thanks,

Paul

1 Answer

0 votes
by (162k points)
Currently you can't change the encoding programmatically.

But you can modify the code to use ISO-8859-1

Hello,

I'm trying to send a text file from a Linux machine to a Windows machine. Since it is a text file, I want to use ASCII mode so the line numbers get changed properly. The problem is that this file has high-byte characters in ISO-8859-1 format, but the "put" method reads the file using a UTF-8 InputStreamReader. As soon as it hits a high-byte character, it dies:

sun.io.MalformedInputException
at sun.io.ByteToCharUTF8.convert(ByteToCharUTF8.java(Compiled Code))
at sun.nio.cs.StreamDecoder$ConverterSD.convertInto(StreamDecoder.java(Inlined Compiled Code))
at sun.nio.cs.StreamDecoder$ConverterSD.implRead(StreamDecoder.java(Compiled Code))
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java(Compiled Code))
at java.io.InputStreamReader.read(InputStreamReader.java(Compiled Code))
at java.io.BufferedReader.fill(BufferedReader.java(Compiled Code))
at java.io.BufferedReader.readLine(BufferedReader.java(Compiled Code))
at java.io.LineNumberReader.readLine(LineNumberReader.java(Compiled Code))
at com.enterprisedt.net.ftp.FTPClient.putASCII(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.put(Unknown Source)
at com.enterprisedt.net.ftp.FTPClient.put(Unknown Source)

Is there some way I can instruct the ftp client to read the file with a given encoding?

Thanks,

Paul

Categories

...