Get Japanese folder name path

Hi everyone

I am using Eclipse to create a Java project named Test under this workspace:
C:\09_あい うえStep1\Program\Suzuki

My project has only one class as below:


public class Test

  public static void main(String[] args)
  public static String getBaseDir()
    String path;
    path = Test.class.getResource(Test.class.getSimpleName() + ".class").getPath();            
    return path;

I ran this project and expected to get:
 C:\09_あい うえStep1\Program\Suzuki\Test\classes\vn\com\abc\Test.class

However, what I'd got was:

This mean that my program doesn't work if I put my project in a path contain Japanese name.

Could you please help me to solve this problem

Many thanks


Who is Participating?
objectsConnect With a Mentor Commented:
you need to convert the url encoded string, try:

path = URLDecoder.decode(path, "UTF8");
getResource() returns a URL, so getPath() is going to return the URL path and not the file path
brimountainAuthor Commented:
Hi objects

I just want to get the full path the file Test.class in runtime.

This statement, path = Test.class.getResource(Test.class.getSimpleName() + ".class").getPath();        

works fine in English name folder, but doens't work in Japanese name folder.  

Is there anyway to get around this problem?  

you may have to convert the path string to unicode bytes using appropriatte charset and then display.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.