Here you can find the source of fileNameDecode(String str)
Parameter | Description |
---|---|
str | the string previously encoded by #fileNameEncode(String) |
public static String fileNameDecode(String str)
//package com.java2s; public class Main { /**//from w w w .j a v a2 s .co m * Decode a string from the encoding used by {@link #fileNameEncode(String)}. * @param str the string previously encoded by {@link #fileNameEncode(String)} * @return the original contents of the string */ public static String fileNameDecode(String str) { StringBuilder sb = new StringBuilder(); int encCharStart, encCharEnd; while ((encCharStart = str.indexOf('[')) != -1 && (encCharEnd = str.indexOf(']')) != -1) { sb.append(str.substring(0, encCharStart)); sb.append((char) Integer.parseInt(str.substring(encCharStart + 1, encCharEnd), 16)); str = encCharEnd == str.length() - 1 ? "" : str.substring(encCharEnd + 1); } sb.append(str); return sb.toString(); } }