写文件 @param file 需要处理的函数 @param str 添加的子字符串 @return 是否成功
(File file, String str)
| 306 | * @return 是否成功 |
| 307 | */ |
| 308 | public static boolean addWrite(File file, String str) { |
| 309 | try ( |
| 310 | RandomAccessFile randomFile = new RandomAccessFile(file, "rw") |
| 311 | ) { |
| 312 | long fileLength = randomFile.length(); |
| 313 | randomFile.seek(fileLength); |
| 314 | randomFile.writeBytes(str); |
| 315 | return true; |
| 316 | } catch (IOException e) { |
| 317 | e.printStackTrace(); |
| 318 | } |
| 319 | return false; |
| 320 | } |
| 321 | |
| 322 | /** |
| 323 | * 写文件 |