Commit 03a756d8 authored by Quxl's avatar Quxl
parents 83144bc0 637e5fec
......@@ -438,10 +438,42 @@ public class FileUtil {
}
}
public static void stringToFileNoLine(File file, String... strings) {
FileOutputStream fos = null;
OutputStreamWriter osw = null;
Writer writer = null;
try {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
fos = new FileOutputStream(file);
osw = new OutputStreamWriter(fos, "UTF-8");
writer = new BufferedWriter(osw);
for (String string : strings) {
writer.append(string);
}
} catch (IOException e) {
throw new FileUtilException(e);
} finally {
try {
writer.close();
osw.close();
fos.close();
} catch (IOException e) {
throw new FileUtilException(e);
}
}
}
public static void stringToFile(String fileFullName, String... strings) {
FileUtil.stringToFile(new File(fileFullName), strings);
}
public static void stringToFileNoLine(String fileFullName, String... strings) {
FileUtil.stringToFileNoLine(new File(fileFullName), strings);
}
public static String fileToString(File file, String charset) {
try {
return new String(FileUtil.fileToBytes(file), charset);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment