Here you can find the source of sanitizeDir(String name)
Parameter | Description |
---|---|
name | The name of the directory to clean. |
public static String sanitizeDir(String name)
//package com.java2s; /* Profile Manager//from w w w . j ava 2s.co m * Copyright (C) 2012 Curtis Oakley * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Takes a directory name and removes any illegal characters and shortens * it to 64 characters if needed. * @param name The name of the directory to clean. * @return The sanitized directory name. */ public static String sanitizeDir(String name) { // Remove illegal characters name = name.replaceAll("[\\\\/:*?\\\"<>|"// Invalid folder chars + "\\x00-\\x1F]", // Control characters ""); // Remove trailing white space name = name.trim(); // Shorten to 64 characters in length if (name.length() > 64) name = name.substring(0, 64); return name; } }