有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java url包含特殊字符

我试图在远程服务器上打开文件,但无法打开,因为url包含特殊字符(#)。 因此url将包含%23个字符

代码如下:

try {

            URL fichierPropertiesPath = getClass().getResource(DAOFactory.FICHIER_PROPERTIES); // url is like /usr/var/tomcat/project#file/dao.properties

            InputStream fichierProperties = fichierPropertiesPath.openStream();
            Properties props = new Properties();
            props.load(fichierProperties);
            props.replace("client", client);

            fichierProperties.close();
            FileOutputStream out = new FileOutputStream(fichierPropertiesPath.getFile());

            props.store(out, null);
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

如何强制URL保留特殊字符

多谢各位


共 (0) 个答案