i deploying application on tomcat server and i use to download file servlet wich calling procedure is
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String reportName = request.getParameter("reportName");
String reportType = request.getParameter("reportType");
String filename = URLDecoder.decode(reportName + "." + reportType, "UTF-8");
String resourcePath = request.getSession().getServletContext().getRealPa th("resources");
String systemPath = System.getProperty("catalina.base");
File file = new File(systemPath + "\\Reports\\", filename);
response.setHeader("Content-Type", getServletContext().getMimeType(file.getName()));
response.setHeader("Content-Length", String.valueOf(file.length()));
response.setHeader("Content-Disposition", "inline; filename=\"" + file.getName() + "\"");

BufferedInputStream input = null;
BufferedOutputStream output = null;

try {
input = new BufferedInputStream(new FileInputStream(file));
output = new BufferedOutputStream(response.getOutputStream());

byte[] buffer = new byte[8192];
for (int length = 0; (length = input.read(buffer)) > 0;) {
output.write(buffer, 0, length);
}
} finally {
if (output != null) {
try {
output.close();
} catch (IOException ignore) {
}
}
if (input != null) {
try {
input.close();
} catch (IOException ignore) {
}
}
}
}
its working fine but, its not returning correct file name when i have non latin alphabet
but when i adding this "response.setCharacterEncoding("UTF-8");"
i getting error "Exception Details: java.nio.charset.MalformedInputException
Input length = 1"
anybody can help me? why i getting error when i adding encodding utf-8?