亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

系統找不到指定的文件

系統找不到指定的文件

fenkapian 2018-02-14 15:56:10
public Map<String, String> getProperties() { ? ? ? ?Properties props = new Properties(); ? ? ? ?Map<String, String> map = new HashMap<>(); ? ? ? ?try {// ? ? ? ? ? ?InputStream in = new FileInputStream("D:\\IntellijWorkspace\\designpattern\\src\\main\\java\\com\\umbrella\\factory\\simple\\type.properties"); ? ? ? ? ? ?InputStream in = new FileInputStream("type.properties"); ? ? ? ? ? ?props.load(in); ? ? ? ? ? ?Enumeration en = props.propertyNames(); ? ? ? ? ? ?while (en.hasMoreElements()) { ? ? ? ? ? ? ? ?String key = (String) en.nextElement(); ? ? ? ? ? ? ? ?String property = (String) props.get(key); ? ? ? ? ? ? ? ?map.put(key, property); ? ? ? ? ? ?} ? ? ? ?} catch (IOException e) { ? ? ? ? ? ?e.printStackTrace(); ? ? ? ?} ? ? ? ?return map; ? ?}要是我這樣用相對路徑就拋異常說找不到文件,要是用上面的絕對路徑就沒錯。相對路徑是絕對沒錯的,這個類和文件都在同一個包下面
查看完整描述

1 回答

?
楠寶寶_

TA貢獻46條經驗 獲得超18個贊

你試下把\換成/

查看完整回答
反對 回復 2018-02-14
  • fenkapian
    fenkapian
    絕對路徑那個是對的啊 現在是用相對路徑就會拋異常
  • 1 回答
  • 0 關注
  • 1198 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號