Π§ΡΠΎ Π½Π΅ ΡΠ°ΠΊ Ρ ΡΡΠΈΠΌ ΠΏΡΠ½ΠΊΡΠΎΠΌ. ΠΠΎΡΠΌΠΎΡΡΠΈΡΠ΅ ΠΏΠΎΠΆΠ°Π»ΡΠΉΡΡΠ°!
package com.javarush.task.task32.task3210;
import java.io.IOException;
import java.io.RandomAccessFile;
public class Solution {
public static void main(String... args) throws IOException {
String fileName = args[0]; // Path to File
int number = Integer.parseInt(args[1]); // Number, it is position
String text = args[2]; // The text for set in the fileName
RandomAccessFile ran = new RandomAccessFile(fileName, "rw");
byte[] buffer = new byte[text.length()];
ran.seek(number);
ran.read(buffer, 0,text.length());
if(buffer.length==text.length()){
ran.seek(ran.length());
String tru = new String("true");
ran.write(tru.getBytes());
} else {
ran.seek(ran.length());
String tru = new String("false");
ran.write(tru.getBytes());
}
ran.close();
}
}