爱问知识人 爱问教育 医院库

Jjava如何读取文件内容的函数?

首页

Jjava如何读取文件内容的函数?

Jjava如何读取文件内容的函数?

提交回答

全部答案

    2018-04-04 06:08:30
  •   public static String readFile(String fileName) {
    String output = "";
    File file = new File(fileName);
    if (file。exists()) {
    if (file。
      isFile()) { try { BufferedReader input = new BufferedReader(new FileReader( file)); StringBuffer buffer = new StringBuffer(); String text; while ((text = input。
      readLine()) != null) buffer。append(text + "\n"); output = buffer。toString(); } catch (IOException ioException) { System。
      err。println("File Error!"); } } else if (file。isDirectory()) { String[] dir = file。list(); output += "Directory contents:\n"; for (int i = 0; i < dir。
      length; i++) { output += dir[i] + "\n"; } } } else { System。err。println("Does not exist!"); } return output; } public static void main(String args[]) { Map ab = new HashMap(); String str = readFile("C:/AbCircuitInfo"); String[] temp=str。
      split("\\n"); for (int i = 0; i < temp。length; i++) { ab。put(temp[i]。substring(0,temp[i]。indexOf(",")), temp[i]。substring(temp[i]。
      indexOf(",")+1,temp[i]。length())); } }。

    不***

    2018-04-04 06:08:30

类似问题

换一换

相关推荐

正在加载...
最新问答 推荐信息 热门专题 热点推荐
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200

热点检索

  • 1-20
  • 21-40
  • 41-60
  • 61-80
  • 81-100
  • 101-120
  • 121-140
  • 141-160
  • 161-180
  • 181-200
返回
顶部
帮助 意见
反馈

确定举报此问题

举报原因(必选):