Last active
July 9, 2018 14:28
-
-
Save steklopod/d1849afb99226707e228bf0bb2d43ff1 to your computer and use it in GitHub Desktop.
С курсором
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.FileNotFoundException; | |
import java.io.IOException; | |
import java.io.RandomAccessFile; | |
/* | |
Запись в существующий файл | |
*/ | |
public class Solution { | |
public static void main(String... args) throws IOException { | |
String fileName = args[0]; | |
long position = Integer.parseInt(args[1]); | |
String text = args[2]; | |
RandomAccessFile file = new RandomAccessFile(fileName, "rw"); | |
position = position > file.length() ? file.length() : position; | |
file.seek(position); | |
file.write(text.getBytes()); | |
file.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment