validfilename.java

来自「一个完整的XACML工程,学习XACML技术的好例子!」· Java 代码 · 共 37 行

JAVA
37
字号
/*
 * ValidFileName.java
 *
 * Created on 17 March 2006, 17:56
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package issrg.config.files;

/**
 *
 * @author ls97
 */
public class ValidFileName {
    
    /** Creates a new instance of ValidFileName */
    public ValidFileName() {
    }
/** to get a valid URL according to a filename
     * @param fileName, which is a file name. The file is allocated in the server at the same
     * directory as this class is
     * @return in, otherwise an exception is thrown
    */    
    public String getName(String fileName) throws ValidFileNameException{
        java.net.URL configURL = this.getClass().getResource(fileName);
        if (configURL == null) {
            throw new ValidFileNameException("file not found: "+fileName);
        }
        String name = configURL.getFile();
        name = name.replaceAll("%20", " ");
        name = name.replace('\\', '/');
        return name;
    }    
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?