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

Method appendLine

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

在文件末尾追加一行 @param file 需要处理的函数 @param str 添加的子字符串 @return 是否成功

(File file, String str)

Source from the content-addressed store, hash-verified

181 * @return 是否成功
182 */
183 public final static boolean appendLine(File file, String str) {
184 try (
185 RandomAccessFile randomFile = new RandomAccessFile(file, "rw")
186 ) {
187 long fileLength = randomFile.length();
188 randomFile.seek(fileLength);
189 randomFile.writeBytes(SysHepler.FILE_SEPARATOR + str);
190 return true;
191 } catch (IOException e) {
192 e.printStackTrace();
193 }
194 return false;
195 }
196
197 /**
198 * 在文件末尾追加一行

Callers 2

testAppendLineMethod · 0.95
testAppendLineMethod · 0.95

Calls 2

getPropertyMethod · 0.80
writeMethod · 0.45

Tested by 2

testAppendLineMethod · 0.76
testAppendLineMethod · 0.76