Here you can find the source of encode(String name)
public static String encode(String name)
//package com.java2s; //License from project: Apache License import java.io.File; import java.io.FileOutputStream; import java.io.IOException; public class Main { public static String encode(String name) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < name.length(); i++) { char c = name.charAt(i); if (c != '_' && Character.isLetterOrDigit(c)) sb.append(c);// w w w . j a v a 2 s .c o m else { String esc = String.format("_%02x", (int) c); sb.append(esc); } } return sb.toString(); } public static void append(File file, byte[] data) { try (FileOutputStream stream = new FileOutputStream(file, true)) { stream.write(data); stream.getChannel().force(true); stream.close(); } catch (IOException e) { throw new RuntimeException(e); } } public static void write(File file, byte[] data) { try (FileOutputStream stream = new FileOutputStream(file)) { stream.write(data); stream.getChannel().force(true); stream.close(); } catch (IOException e) { throw new RuntimeException(e); } } }