亚洲精品中文字幕无乱码_久久亚洲精品无码AV大片_最新国产免费Av网址_国产精品3级片

SUN認證

SUN認證考試知識點:java讀取文件內容的函數(shù)

時間:2024-09-10 00:47:46 SUN認證 我要投稿
  • 相關推薦

SUN認證考試知識點:java讀取文件內容的函數(shù)

  public static String readFile(String fileName) {

SUN認證考試知識點:java讀取文件內容的函數(shù)

  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()));

  }

  }

【SUN認證考試知識點:java讀取文件內容的函數(shù)】相關文章:

Sun java認證考試答案10-23

Sun認證Java開發(fā)員考試介紹06-25

java認證考試培訓內容08-21

sun java認證考試題庫09-04

sun認證java程序員考試科目10-01

sun認證java程序員08-05

sun認證java基礎模擬試題09-16

sun認證java程序員考試試題09-13

Sun認證Java程序員考試技巧分享09-14

SUN認證考試流程08-22