See my previous question: Cannot write chinese characters to a filename This question is similar to that but a slight change, causes the solution in that question to no longer work.
I am now trying to take in a filename as a program argument and if the characters are Chinese (or Japanese or similar) they will be swapped to ?
and I will get an exception.
Run Configurations > Common > Encoding = UTF-8
Program Arguments: 你好.txt
Main:
public static void main(String[] args) throws IOException
{
String fileName = args[0];
Writer out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream("C:/temp/"+fileName+".txt"), "UTF-8"));//Ex thrown
out.close();
}
Exception: Exception in thread "main" java.io.FileNotFoundException: C:\temp\??.txt.txt (The filename, directory name, or volume label syntax is incorrect)
How can I make this work?