小弟我问个java输出流的基本问题

就是最近想向*.properties里面输出 \ 但是发现控制台打印出来是\
但是实际*.properties里面却是\

因为"\"是转译字符,所以在代码里面只输出"\"是会报错的。。。。

请问各位大哥谁能教我下怎么向*.properties里面输出\啊

文件和控制台都是

ccc\

[color=blue][b]把你要输出的一个\ 换成 4个 \ ,试试:

\ --> \\[/b][/color]

如果你控制台输出\,写入到文件也应该是\,你可以贴一下你的代码。

测试过没有问题。
[code="java"] public static void main(String[] args) {
try {
FileWriter fw = new FileWriter("e:/b.txt");
BufferedWriter bw = new BufferedWriter(fw);
String myreadline = "ccc\";
System.out.println(myreadline);
bw.write(myreadline);
bw.flush();
bw.close();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}[/code]

[b]你如果是想输出中文的话,可以直接使用:[/b]

[code="java"]public static void main(String[] agrs) throws Exception {

    String str ="你好";
    Properties prop = new Properties();
    prop.setProperty("aa", str);
    prop.store(new FileOutputStream("src/aaa.properties"), "no common");
}[/code]

[b]结果:[/b]
[code="java"]#no common
#Wed Apr 07 10:36:14 CST 2010
aa=\u4F60\u597D[/code]