javawindowsutf-8cp1252

How to create a directory with different language name in java?


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?


Solution

  • 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();
    }