欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

生成html

程序员文章站 2022-05-26 23:40:58
...
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class FileReaderUtil {

/**
* 读文件到String
* @param fileName
* @return
* @throws Exception
*/
public static String readFile(String fileName) throws Exception {

File myFile=new File(fileName);
String fileContent = "";
if(!myFile.exists())
{
System.err.println("Can't Find " + fileName);
}

try
{
BufferedReader in = new BufferedReader(new FileReader(myFile));
String str ;
while ((str = in.readLine()) != null)
{
fileContent = fileContent + str ;
}
in.close();
}
catch (IOException e)
{
e.getStackTrace();
}
return fileContent;
}

}
相关标签: HTML Java