1

I am trying to create a directory with different language name in java, but the directory is not generated and appearing as "?????" in log.

{

        String strtobyte = "对不起拜托";
        byte[] b = strtobyte.getBytes(("Windows-1252"));
        String bytetostr = new String(b);
        tmpDir = new File(this.m_directory, bytetostr);
    }

Can someone please help me to create directory with different language names?

Jagadesh
  • 2,104
  • 1
  • 16
  • 28
  • Does this answer your question? [Encoding of file names in Java](https://stackoverflow.com/questions/10106161/encoding-of-file-names-in-java) – serges_newj Apr 27 '20 at 04:46

1 Answers1

1

Use "UTF-8", instead of "Windows-1252".

Or, you can just do it like this:

public static void main(String[] args)
{
    File f = new File("/Users/foldername", "对不起拜托");
    f.mkdir();
}
geffchang
  • 3,279
  • 2
  • 32
  • 58