I made a method that takes a File and a String. It replaces the file with a new file with that string as its contents.
File
String
This is what I made
Try using memory mapped files:
FileChannel rwChannel = new RandomAccessFile("textfile.txt", "rw").getChannel(); ByteBuffer wrBuf = rwChannel.map(FileChannel.MapMode.READ_WRITE, 0, textToSave.length()); wrBuf.put(textToSave.getBytes()); rwChannel.close();