删除 src/main/java/com/bonus/autoweb/base/AutoUtils.java
This commit is contained in:
parent
b3d661ccaf
commit
9943d7cebd
|
|
@ -1,54 +0,0 @@
|
|||
package com.bonus.autoweb.base;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
|
||||
|
||||
public class AutoUtils {
|
||||
|
||||
|
||||
/**
|
||||
* 向text写入数据
|
||||
* @param filename
|
||||
* @param content
|
||||
*/
|
||||
public static int write(String filename, String content) {
|
||||
int code = 0;
|
||||
try {
|
||||
FileOutputStream fos = new FileOutputStream(filename);
|
||||
OutputStreamWriter osw = new OutputStreamWriter(fos, "UTF-8");
|
||||
BufferedWriter writer = new BufferedWriter(osw);
|
||||
writer.write(content);
|
||||
writer.close();
|
||||
System.out.println("Text file generated successfully.");
|
||||
code = 1;
|
||||
} catch (IOException e) {
|
||||
code = 0;
|
||||
System.out.println("An error occurred while generating the text file.");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return code;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从text读取数据
|
||||
* @param filename
|
||||
*/
|
||||
public static String read(String filename){
|
||||
StringBuilder content = new StringBuilder();
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new FileReader(filename));
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
content.append(line).append("\n");
|
||||
}
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
System.out.println("An error occurred while reading the text file.");
|
||||
content.append("error");
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content.toString();
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue