suresh krishna
suresh krishna

Reputation: 13

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?

Upvotes: 1

Views: 106

Answers (1)

geffchang
geffchang

Reputation: 3340

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

Upvotes: 1

Related Questions