2
Q
由於\
A
回答
4
每當你需要使用\
時間,寫兩個:\\
。換句話說:你需要逃避它,因爲\
角色本身就是逃跑角色,它也需要逃脫!
或者,對於文件路徑,您可以使用單個/
,這與您所在的平臺(Windows,Linux,Mac等)無關。
回到你的問題:這有點奇怪,發生這種情況時,getenv
返回的字符串肯定已經逃脫了\
這個字符。讓我們嘗試使用,需要一個File
代替constructor:
FileOutputStream fos = new FileOutputStream(new File(System.getenv("APPDATA")));
0
File f = new File(System.getenv("APPDATA"));
System.out.println(f.getAbsolutePath());
然後你就可以構造一個新的(F)FileOutputStream中;
相關問題
- 1. 由於titleForHeaderInSection
- 2. 由於:java.lang.ClassNotFoundException:com.amazonaws.services.dynamodbv2.model.PutItemRequest
- 3. 由於'ACTIVE_TRANSACTION
- 4. 由於版本
- 5. 由於SelectedIndex
- 6. 由於ContextSwitchDeadlock
- 7. 由於webpart
- 8. 由於PIC(NASM)
- 9. 由於Msg 8116
- 10. 由於System.IO.FileFormatException()
- 11. 由於'character
- 12. 由於「UIRequiredDeviceCapabilities」
- 13. System.AccessViolationException由於System.Data.Objects.ObjectQuery
- 14. 由於DataAdapter.Fill()
- 15. 由於* ngIf
- 16. 由於El Capitan
- 17. 'System.Reflection.TargetInvocationException'由於routes.MapMvcAttributeRoutes()
- 18. Arduino由於PWM
- 19. 由於SonarQube 5.2
- 20. System.AccessViolation由於Marshal.StructureToPtr
- 21. 由於Double.parseDouble
- 22. 由於遞歸
- 23. 由於:錯誤:[$ injector:nomod]
- 24. 問題由於getAdapterPosition
- 25. 錯誤:[$ injector:modulerr]由於
- 26. ASP.NET Page_Load由於Bitmap.Save
- 27. 由於路由無效,彈簧路由獲取404錯誤
- 28. MySQL的計數由於
- 29. NaN由於未知原因
- 30. 錯編碼由回覆於
如果你真的想使用'/',那麼只需要這樣做:'System.getenv(「APPDATA」)。replace('\','/')' – 2013-03-08 20:10:59
謝謝!我將用它來做我的程序。 – Mad3ngineer 2013-03-08 20:12:11