无法使用servler在.txt文件中下载THAI字符。 当我点击下载时,THAI字符在文件中显示为???生成的文件格式为UNIX,FILE Type为ANSI。但我需要生成正确的THAI字符以及正确的文件格式,即Windows和ANSI。
请注意,我已使用所有可能的字符编码组合。 下面是我用来下载文件的代码。
提前致谢,任何有用的帮助。
ftp=new FTPClient();
ftp = Utilities.getFTPConnection(ftpServerIP, ftpUserName, ftpPassword);
retValue = ftp.changeWorkingDirectory(uploadRoot);
Value = ftp.retrieveFile(fileName, new FileOutputStream( downloadFile ));
if (!Value)
{
throw new Exception ("Downloading of remote file "+downloadFile.getName()+" failed. ftp.retrieveFile() returned false.");
}
isSuccess = true;
}
}
catch(Exception e)
{
}
finally
{
Connection Close Code
downloadFile.exists();
}
InputStream in = null;
PrintWriter printWriter = null;
DataInputStream dataInputStream = null;
BufferedReader bufferReaderFile = null;
String strLineFromFile;
try
{
File f= new File(uploadPath+File.separator+clientCode+File.separator+fileName);
if(f.exists())
{
result=Action.SUCCESS;
response.reset();
response.setCharacterEncoding("US-ASCII");
response.setContentType("application/x-download");
response.setHeader("Cache-Control", "max-age=0");
response.setHeader("Content-Disposition","attachment;filename="+ fileName);
in = new FileInputStream(f);
dataInputStream = new DataInputStream(in);
bufferReaderFile = new BufferedReader(new InputStreamReader(dataInputStream,"US-ASCII"));
printWriter=response.getWriter();
byte[] buf = new byte[8192];
int sizeRead = 0;
while ((sizeRead = in.read(buf, 0, buf.length)) > 0)
{
outStream.write(buf,0,sizeRead);
}
while ((strLineFromFile = bufferReaderFile.readLine()) != null)
{
printWriter.println(strLineFromFile);
outStream.print("\n\r");
}
printWriter.flush();
printWriter.close();
bufferReaderFile.close();
dataInputStream.close();
in.close();
答案 0 :(得分:0)
我成功地在泰语 Charcters中编写了文件,但为此我使用 TIS-620 从LINUX服务器读取fille内容并在编写文件时使用UTF-8格式,以适当的格式为泰国字符生成文件。 但是当我们在 NOTEPAD ++ 中打开该文件时,这会给出一个修改,我们必须更改文件编码格式。