位置: 首頁 > IT認證 > SUN認證

SUN認證考試知識點:java讀取檔案內容的函式

2017-12-13 SUN認證

public static String readFile(String fileName) {

String output = "";

File file = new File(fileName);

if (ts()) {

if (le()) {

try {

BufferedReader input = new BufferedReader(new FileReader(

file));

StringBuffer buffer = new StringBuffer();

String text;

while ((text = Line()) != null)

nd(text + "n");

output = ring();

} catch (IOException ioException) {

tln("File Error!");

}

} else if (rectory()) {

String[] dir = ();

output += "Directory contents:n";

for (int i = 0; i < th; i++) {

output += dir[i] + "n";

}

}

} else {

tln("Does not exist!");

}

return output;

}

public static void main(String args[]) {

Map ab = new HashMap();

String str = readFile("C:/AbCircuitInfo");

String[] temp=t("n");

for (int i = 0; i < th; i++) {

(temp[i]tring(0,temp[i]xOf(",")), temp[i]tring(temp[i]xOf(",")+1,temp[i]th()));

}

}

標籤:知識點 Sun JAVA 讀取 考試
2017-12-13
2016-10-24
2016-01-01
2019-10-25
2016-08-22
2017-12-16
2015-02-07
2016-04-10
2017-12-13
2017-12-13

Copyright ©2024 才華齋 All Rights Reserved.