我在SVN的存儲庫中有文件夾,其名稱中包含一個en-dash(「\ u2013」) 。 我首先調用「svn list」(以我的Windows 7 + UTF-8編碼)來獲取目錄列表。 在調用BufferedReader readLine()之後,它讀取列表的文本。 正在顯示的文件夾的名稱包含連字符(「\ u002D」)而不是連字符(「\ u2013」)。BufferedReader方法ReadLine()將en-dash(「 u2013」)轉換爲連字符(「 u002D」)
對此有任何限制嗎?
class Test {
public static void main(String args[]) {
BufferedReader br = null;
try {
String sCurrentLine;
br = new BufferedReader(new FileReader("C:\\test–ing.xml"));
System.out.println(br.readLine());
while ((sCurrentLine = br.readLine()) != null) {
System.out.println(sCurrentLine);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (br != null)
br.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}
} // end main
您可能想要發佈一些代碼。我不清楚svn命令和Java程序是如何協同工作以及如何創建'BufferedReader'實例的。 – Codo
你可以試試這個: 類測試{ \t公共靜態無效的主要(字符串ARGS []){ \t \t的BufferedReader BR = NULL; \t \t嘗試{ \t \t \t字符串sCurrentLine; \t \t \t br = new BufferedReader(new FileReader(「C:\\ test-ing.xml」)); \t \t \t System.out.println(br.readLine()); \t \t \t而((sCurrentLine = br.readLine())!= NULL){ \t \t \t \t的System.out.println(sCurrentLine); \t \t \t} \t \t}趕上(IOException的發送){ \t \t \t e.printStackTrace(); \t \t} {終於 \t \t \t嘗試{ \t \t \t \t如果(BR!= NULL) \t \t \t \t \t BR。關(); \t \t \t}趕上(IOException異常前){ \t \t \t \t ex.printStackTrace(); \t \t \t} \t \t} \t} //結束主 –
我加你的代碼的問題。但我仍然不明白它與svn命令的關係。 – Codo