My goal is to read files names from a folder and send these names over the network. Often file names contains foreign characters. For example, one file can be in Russian and another one in Hebrew.
How do I know what is the charset of a given file name?
I guess once I know the charset, I can use the same charset to recreate the the String from byte array.
Why should you have to know that? And what could you do if you did? All of the methods in the File API already return you file names as Strings.
And besides, "the charset of a String" is not a meaningful concept.
Thanks for your reply. On the client's end I need to convert the String into byte array, send these bytes over the network and recreate the string on the server's end. When I use fileName.getBytes(), it works if the file name is in English - meaning I can use the new String(byte) constructor to recreate the name. However, if the file name on the client is in a foreign language, I get question marks on the server's end.
I want to use the fileName.getBytes("charset") method instead to create the byte array so that it keeps the character sets intact.