Java 类org.apache.commons.fileupload.InvalidFileNameException 实例源码

项目:WidgetStore    文件:Streams.java   
/**
 * Checks, whether the given file name is valid in the sense,
 * that it doesn't contain any NUL characters. If the file name
 * is valid, it will be returned without any modifications. Otherwise,
 * an {@link InvalidFileNameException} is raised.
 *
 * @param fileName The file name to check
 * @return Unmodified file name, if valid.
 * @throws InvalidFileNameException The file name was found to be invalid.
 */
public static String checkFileName(String fileName) {
    if (fileName != null  &&  fileName.indexOf('\u0000') != -1) {
        // pFileName.replace("\u0000", "\\0")
        final StringBuilder sb = new StringBuilder();
        for (int i = 0;  i < fileName.length();  i++) {
            char c = fileName.charAt(i);
            switch (c) {
                case 0:
                    sb.append("\\0");
                    break;
                default:
                    sb.append(c);
                    break;
            }
        }
        throw new InvalidFileNameException(fileName,
                "Invalid file name: " + sb);
    }
    return fileName;
}
项目:cim    文件:Streams.java   
/**
 * Checks, whether the given file name is valid in the sense,
 * that it doesn't contain any NUL characters. If the file name
 * is valid, it will be returned without any modifications. Otherwise,
 * an {@link InvalidFileNameException} is raised.
 *
 * @param pFileName The file name to check
 * @return Unmodified file name, if valid.
 * @throws InvalidFileNameException The file name was found to be invalid.
 */
public static String checkFileName(String pFileName) {
    if (pFileName != null  &&  pFileName.indexOf('\u0000') != -1) {
        // pFileName.replace("\u0000", "\\0")
        final StringBuffer sb = new StringBuffer();
        for (int i = 0;  i < pFileName.length();  i++) {
            char c = pFileName.charAt(i);
            switch (c) {
                case 0:
                    sb.append("\\0");
                    break;
                default:
                    sb.append(c);
                    break;
            }
        }
        throw new InvalidFileNameException(pFileName,
                "Invalid file name: " + sb);
    }
    return pFileName;
}
项目:AndroidWebServ    文件:Streams.java   
/**
 * Checks, whether the given file name is valid in the sense,
 * that it doesn't contain any NUL characters. If the file name
 * is valid, it will be returned without any modifications. Otherwise,
 * an {@link InvalidFileNameException} is raised.
 *
 * @param pFileName The file name to check
 * @return Unmodified file name, if valid.
 * @throws InvalidFileNameException The file name was found to be invalid.
 */
public static String checkFileName(String pFileName) {
    if (pFileName != null  &&  pFileName.indexOf('\u0000') != -1) {
        // pFileName.replace("\u0000", "\\0")
        final StringBuffer sb = new StringBuffer();
        for (int i = 0;  i < pFileName.length();  i++) {
            char c = pFileName.charAt(i);
            switch (c) {
                case 0:
                    sb.append("\\0");
                    break;
                default:
                    sb.append(c);
                    break;
            }
        }
        throw new InvalidFileNameException(pFileName,
                "Invalid file name: " + sb);
    }
    return pFileName;
}
项目:metl    文件:DatabaseScript.java   
public void parse(String fileName) {
    String[] parts = fileName.split(DELIMITER_MAIN);
    if (parts.length != 4) {
        throw new InvalidFileNameException(fileName, "Database scripts must have 3 parts : version_when_order_description.sql");
    }
    parseVersion(parts[0]);
    when = parseWhen(parts[1]);
    order = new Integer(parts[2]);
    parseDescription(parts[3]);

}