一个简单的函数,传入文件名,返回文件字符串. public String Read(String filePath) throws Exception ... { String ret=""; File fl = new File(filePath); FileReader fileReader = new FileReader(fl); BufferedReader bufferedReader = new BufferedReader(fileReader); String line; while( (line = bufferedReader.readLine()) != null )...{ ret =ret + line; } return ret; } 需要导入的包 import java.io.BufferedReader;import java.io.File;import java.io.FileReader;