Java tutorial
//package com.java2s; //License from project: GNU General Public License public class Main { /** * sanitize the filename * @param fileName * @return */ static String validateFileName(String fileName) { if (fileName == null) return null; fileName = fileName.replace('/', '_'); fileName = fileName.replace('<', '_'); fileName = fileName.replace('>', '_'); fileName = fileName.replace(':', '_'); fileName = fileName.replace('\'', '_'); fileName = fileName.replace('?', '_'); fileName = fileName.replace('"', '_'); fileName = fileName.replace('|', '_'); fileName = fileName.replace('(', '_'); fileName = fileName.replace(')', '_'); fileName = fileName.replace('[', '_'); fileName = fileName.replace(']', '_'); fileName = fileName.replaceAll("%", ""); return fileName; } }