English 中文(简体)
将2颗斜体改为1
原标题:replace 2 backslashes to one
  • 时间:2011-11-22 10:03:33
  •  标签:
  • java
  • regex

我接过这些问题,找不到解决办法。

我有财产档案,用户储存档案的位置。

e.g:

location = C:images

在对他的答复中,我不得不印刷地点财产,并照此印刷:

C:images

如果我住址:

C:\images\

它照此印刷(例如,它没有处理插曲):

C:\images\

我愿简单地将其印成<代码>C:images。

我如何能够这样做?

This also applies to where I want to write an HTML tag like this:

<img src = "+locations+" >

多数浏览器会用两重弹抽出该地点,但我并不喜欢依赖。

http://www.ohchr.org。

我抱歉——我的错误。 现在的问题是罚款。 请忽视C:网络浏览器不能访问C。

http://www.ohchr.org。

我正在利用Jerrsey执行客户反应,后者正在利用Jax-B撰写这种答复:

    com.sun.jersey.core.provider.jaxb.AbstractRootElementProvider.writeTo(Object t, MediaType mediaType, Charset c, Marshaller m, OutputStream entityStream) throws JAXBException:

 protected void writeTo(Object t, MediaType mediaType, Charset c,
            Marshaller m, OutputStream entityStream)
            throws JAXBException {
        m.marshal(t, entityStream);
    }

产出流为com.sun.jersey.spi.container.ContainerResponse.CommittingOutputStream

我看到,这些财产只装载了1件。

我从WizTools.org获得我的其余客户工具的答复。

这个问题吗?

问题回答

你们需要避免反弹,但不要 forward。 因此,如果你有财产档案:

location = c:\images\

这应当罚款。

例如,这里有一个小的青少年:

import java.io.*;
import java.util.*;

public class Test {
    public static void main(String[] args) throws Exception {
        Properties properties = new Properties();
        // Would normally close the stream, of course :)
        properties.load(new FileInputStream("test.properties"));
        System.out.println(properties.getProperty("location"));
    }
}

试卷:just<>/em>载有前面所示线的“properties file”,在“c:images/code”上打印,没有任何问题。

使用斜坡容易发生错误。 请使用

location=file:/C:/images/

或(在无线索的情况下建议其夹)

directory=file:/C:/images

关于

The specification for the format of a Java properties file is in the javadoc for the Properties.load(Reader) method. It clearly states that a backslash must be escaped. It also states that a backslash that is followed by some character other than valid escapes is silently dropped.

I can only conclude that you are not using one of the load methods of the Properties object to load the properties from your file. And, in effect, you are not following the Java properties file specification.

You may have some reason to do both of these things, but if you do then you shouldn t be calling your non-standard file format "properties files" ... because people expect Java property files to follow the specification.


However, I d recommend that you just use the standard format / specification, and that you just use Properties.load(...) and Properties.save(...) to read and write properties files.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...