Solved

Get Japanese folder name path

Posted on 2006-07-02
4
381 Views
Last Modified: 2010-10-05
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 Test.java as below:

package vn.com.abc;

public class Test
{

  public static void main(String[] args)
  {
     System.out.println(getFullPath());
  }
      
  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:
 /C:/09_%e3%81%82%e3%81%84%e3%80%80%e3%81%86%e3%81%88Step1/Program/Suzuki/Test/classes/vn/com/abc/Test.class

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

Brimountain


0
Comment
Question by:brimountain
  • 2
4 Comments
 
LVL 92

Expert Comment

by:objects
Comment Utility
getResource() returns a URL, so getPath() is going to return the URL path and not the file path
0
 

Author Comment

by:brimountain
Comment Utility
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?  

Bri
0
 
LVL 92

Accepted Solution

by:
objects earned 500 total points
Comment Utility
you need to convert the url encoded string, try:

path = URLDecoder.decode(path, "UTF8");
0
 
LVL 26

Expert Comment

by:ksivananth
Comment Utility
you may have to convert the path string to unicode bytes using appropriatte charset and then display.
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now