How can i set localized filenames in java.Currently everytime i click on a localized file having a non-ascii filename in my application, the windows save dialog box pops out, bu
I faced similar problems with filenames containing greek characters.I used the code provided in the answer above (my thanks to dkarp) combined with detecting which browser is used. this is the result:
String user_agent = request.getHeader("user-agent"); boolean isInternetExplorer = (user_agent.indexOf("MSIE") > -1); if (isInternetExplorer) { response.setHeader("Content-disposition", "attachment; filename=\"" + URLEncoder.encode(filename, "utf-8") + "\""); } else { response.setHeader("Content-disposition", "attachment; filename=\"" + MimeUtility.encodeWord(filename) + "\""); }
I tested it with firefox 3.6 , chrome 10.0 and Internet Explorer 8 and it seems to work fine.