Commit 1c11b9b7 authored by 张永's avatar 张永

加个方法

parent 3c0d7031
...@@ -430,10 +430,42 @@ public class FileUtil { ...@@ -430,10 +430,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) { public static void stringToFile(String fileFullName, String... strings) {
FileUtil.stringToFile(new File(fileFullName), 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) { public static String fileToString(File file, String charset) {
try { try {
return new String(FileUtil.fileToBytes(file), charset); 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