- /**=======================================================================**
- * [## public static void createCheckFile(String filePath, String detail) throws {} ] :
- * 参数 :filepath文件路径名称
- * detail等待写入文件的内容
- * 返回值 :无
- * 修饰符 :public static 可以不实例化对象而直接调用方法
- * 功能 :将detail写入指定的路径文件中
- **=======================================================================**/
- public static void createCheckFile(String filePath, String detail) throws
- Exception {
- try {
- File file = new File(filePath);
- FileWriter filewriter = new FileWriter(file, false); //false表示不追加内容
- filewriter.write(detail);
- filewriter.close();
- } catch (IOException e) {
- throw e;
- } catch (Exception ex) {
- throw ex;
- }
- }
- /**=======================================================================**
- * [## public static String readCheckFile(String filePath) throws {} ] :
- * 参数 :filepath文件路径名称
- * 返回值 :无
- * 修饰符 :public static 可以不实例化对象而直接调用方法
- * 功能 :返回指定的路径文件中的内容
- **=======================================================================**/
- public static String readCheckFile(String filePath) throws Exception {
- BufferedReader bufread;
- String read, readStr;
- readStr = "";
- try {
- File file = new File(filePath);
- FileReader fileread = new FileReader(file);
- bufread = new BufferedReader(fileread);
- while ((read = bufread.readLine()) != null) {
- readStr = readStr + read;
- }
- } catch (Exception d) {
- System.out.println(d.getMessage());
- }
- return readStr; //返回从文本文件中读取内容
- }