Here you can find the source of filenameEncode(String string)
Parameter | Description |
---|---|
string | the string to encode. |
public static String filenameEncode(String string)
//package com.java2s; public class Main { private static final String ILLEGAL_FILENAME_CHARS_REGEX = "[/\\?%*:|\"'<>.]"; /**//from w w w . j a v a2 s . c o m * Encodes the given string by removing chars which are illegal on most file * systems. * * @param string the string to encode. * @return an encoded filename string. */ public static String filenameEncode(String string) { if (string != null) { string = string.replaceAll(ILLEGAL_FILENAME_CHARS_REGEX, ""); if (string.length() > 255) { string = string.substring(0, 255); } } return string; } }