Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Get Japanese folder name path

Posted on 2006-07-02
4
Medium Priority
?
436 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 92

Expert Comment

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

Author Comment

by:brimountain
ID: 17028847
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 2000 total points
ID: 17028853
you need to convert the url encoded string, try:

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

Expert Comment

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

597 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