MCPcopy Create free account
hub / github.com/0opslab/opslabJutil / writeAppend

Method writeAppend

src/main/java/com/opslab/util/FileUtil.java:237–249  ·  view source on GitHub ↗

将字符串以追加的方式写入到文件中

(File file, String str)

Source from the content-addressed store, hash-verified

235 * 将字符串以追加的方式写入到文件中
236 */
237 public final static boolean writeAppend(File file, String str) {
238 try (
239 RandomAccessFile randomFile = new RandomAccessFile(file, "rw")
240 ) {
241 long fileLength = randomFile.length();
242 randomFile.seek(fileLength);
243 randomFile.writeBytes(str);
244 return true;
245 } catch (IOException e) {
246 e.printStackTrace();
247 }
248 return false;
249 }
250
251 /**
252 * 将字符串以制定的编码写入到文件中

Callers 2

testWriteFileMethod · 0.95
testWriteFileMethod · 0.95

Calls 1

writeMethod · 0.45

Tested by 2

testWriteFileMethod · 0.76
testWriteFileMethod · 0.76