public static void main(String... args) throws IOException {
int number = Integer.parseInt(args[1]);
String text = args[2];
RandomAccessFile randomAccessFile = new RandomAccessFile(args[0], "rw");
byte[] massive = new byte[number + text.length()];
randomAccessFile.seek(number);
randomAccessFile.read(massive, number, text.length());
String result = new String(massive).trim().intern();
randomAccessFile.seek(randomAccessFile.length());
if (result.equals(text)) {
randomAccessFile.write("true".getBytes());
} else randomAccessFile.write("false".getBytes());
randomAccessFile.close();
}
package com.javarush.task.task32.task3210;
import java.io.IOException;
import java.io.RandomAccessFile;
/*
Используем RandomAccessFile
*/
public class Solution {
public static void main(String... args) throws IOException {
int number = Integer.parseInt(args[1]);
String text = args[2];
RandomAccessFile randomAccessFile = new RandomAccessFile(args[0], "rw");
byte[] massive = new byte[number + text.length()];
randomAccessFile.seek(number);
randomAccessFile.read(massive, number, text.length());
String result = new String(massive).trim().intern();
randomAccessFile.seek(randomAccessFile.length());
if (result.equals(text)) {
randomAccessFile.write("true".getBytes());
} else randomAccessFile.write("false".getBytes());
randomAccessFile.close();
}
}