Java tutorial
//package com.java2s; import java.io.File; import java.io.UnsupportedEncodingException; public class Main { public static File getRealFileName(String baseDir, String absFileName) { String[] dirs = absFileName.split("/"); File ret = new File(baseDir); String substr = null; if (dirs.length > 1) { for (int i = 0; i < dirs.length - 1; i++) { substr = dirs[i]; try { // substr.trim(); substr = new String(substr.getBytes("8859_1"), "GB2312"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } ret = new File(ret, substr); } if (!ret.exists()) ret.mkdirs(); substr = dirs[dirs.length - 1]; // try { substr.trim(); ret = new File(ret, substr); return ret; } return ret; } }