我正在與java.io.File一起處理外部存儲器上的某些PDF文件。我正在加載它們,並注意到我的日誌中有一些File NotFoundExceptions
。我正在尋找異常,並注意到一個奇怪的標誌(?
內部= )UNC。Java - 在UNC中找不到ö或ü的文件
這就是我如何製作我的文件。如果這有所幫助,我可以從緩衝讀取器中獲取字符串。
File myPathFile
FileReader fr = new FileReader(myPathFile);
BufferedReader br = new BufferedReader(fr)
String o = br.readLine();
File f = new File(o)
我還以爲是一樣的:
File f = new File("\\test\ö\myFile.pdf"); //When the UNC looks like this it won't work. (the ö is �)
File f2 = new File("\\test\myFile.pdf"); //This works
你確定這是你的代碼嗎?它甚至不應該編譯...'\ m'不是有效的轉義。請參閱http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.10。6 –
這不是一個URL,即UNC。 –