将字符串以追加的方式写入到文件中
(File file, String str)
| 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 | * 将字符串以制定的编码写入到文件中 |