SUN认证考试知识点:java读取文件内容的函数

public static String readFile(String fileName) {

SUN认证考试知识点:java读取文件内容的函数

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

}

}