I am generating a pdf which should be named something like this, "ウェブドメイン.pdf", but when I pass this filename into the FileOutputStream, it doesn't created the expected filename with UTF-8 encoding but instead it creates a file with a name like ???????.pdf.
I am using the following code to do the same, and I don't understand why is it behaving like this.
String fileName="ウェブドメイン.pdf";
FileOutputStream fileOutputStream = new FileOutputStream(new String(fileName.getBytes("UTF-8"),"UTF-8"));
PdfWriter writer = PdfWriter.getInstance(document,fileOutputStream);
Anyone having ideas on how to solve this problem. Any help will be appreciated.
In a Unix system, native code libraries seemingly pull the encoding information from LC_CTYPE
environment variables to determine file encoding, instead of getting the value from -Dfile.encoding=utf-8
java system setting.
If you export LANG=en_US.UTF-8
your system environment, the native parts of java stack will treat your UTF filenames accordingly.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.