在配置文件a.properties中有一行
path=C:\test
在java中getProperty("path")后,java把\t认为是一个字符TAB。
怎样才能取到正确的结果:C:\test,不能使用替换\t的方法,这样不通用,因为可能还会有\n等。
path=C:\test
在java中getProperty("path")后,java把\t认为是一个字符TAB。
怎样才能取到正确的结果:C:\test,不能使用替换\t的方法,这样不通用,因为可能还会有\n等。
不行吗 说老实话 我也 没怎么看懂你的意思
properties文件都需要注意这个问题啊喵~~`
使用C:\\test或者C:/test...
File f=new File(myPath+“\\+myFileName);
c:\\test
c:/test
当然了“\”应用“\\”进行转义。
File f = new File("a.properties");
Properties pos = new Properties();
pos.load(new FileInputStream(f));
re=pos.getProperty("path");
String ff = re.subSequence(0, re.indexOf("\t"))+"\\t" + re.subSequence(re.indexOf("\t")+1, pt.re.length());
Properties pos = new Properties();
pos.load(new FileInputStream(f));
re=pos.getProperty("path");
String ff = re.subSequence(0, re.indexOf("\t"))+"\\t" + re.subSequence(re.indexOf("\t")+1,re.length());
c:\\test
c:/test
嘿嘿,kokobox 搬好家别忘记散分哦~~
当然了“\”应用“\\”进行转义。
可以用这个.
File.separator
哦!!我明白了,LZ想去SUN公司 工作!!
在windows 下 直接转意就可以了
比如 C:\\TEST.txt如果在LIKE UNIX下 可以用 平台相关File.separator
在写JDBC连接路径的时候也要"..\\..\\...\\",不知道是不是LZ的意思
the format like this~
向各位学习!
还有什么File.separator的,根本不着调。
靠谱的同志很少。还有人说200分啥的,分有什么用?这个小问题都没人搞的定,真遇到难度大的,会有人解答的出么?鉴于这个贴子这么受关注,我就等一段小时间再结账啦,哈哈。
File f = new File("a.properties");
Properties pos = new Properties();
pos.load(new FileInputStream(f));
re=pos.getProperty("path");
String ff = re.subSequence(0, re.indexOf("\t"))+"\\t" + re.subSequence(re.indexOf("\t")+1, pt.re.length());
挑战技术,超越自我!!