Solved

Get Japanese folder name path

Posted on 2006-07-02
4
414 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 500 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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 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 basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
Suggested Courses

737 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