В 24 строке выдает:
Exception in thread "main" java.lang.IndexOutOfBoundsException
at java.io.RandomAccessFile.readBytes(Native Method)
at java.io.RandomAccessFile.read(RandomAccessFile.java:377)
at Solution.main(Solution.java:33)
файл длиной 18, арг(1) == 8 арг(2).лен == 3 , как это возможно? меняют на любые параметры, такая же история, где я туплю друзья?
package com.javarush.task.task32.task3210;
/*
Используем RandomAccessFile
*/
import java.io.IOException;
import java.io.RandomAccessFile;
public class Solution {
public static void main(String[] args) throws IOException
{
RandomAccessFile randomAccessFile = new RandomAccessFile(args[0], "rw");
if (randomAccessFile.length() >= Long.parseLong(args[1]))
{
randomAccessFile.seek(Long.parseLong(args[1]));
}
else
{
randomAccessFile.seek(randomAccessFile.length());
}
byte [] allBytes = new byte [args[2].length()];
randomAccessFile.read(allBytes,Integer.parseInt(args[1]),allBytes.length);
randomAccessFile.seek(randomAccessFile.length());
if (args[2].equals(new String(allBytes)))
{
randomAccessFile.write("true".getBytes());
}
else
{
randomAccessFile.write("false".getBytes());
}
randomAccessFile.close();
}
}