Solved

Get Japanese folder name path

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
allswap challenge 6 98
reverse digits of a number using for loop 5 41
null output 3 25
How do I remove an object from a 3 26
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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…

772 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