C
C
Chvalov2016-03-21 09:48:37
Java
Chvalov, 2016-03-21 09:48:37

How to correctly implement a file offset and pull out the desired part of the bytes into a new file?

There is a 4-5Mb file, if you look at it with a hex editor, then everything is quite simple and fast.
I also have a document with offsets for this file, everything from the beginning to the end of the offset is a new file.
For example, the beginning of the file went from 49AFC to F823F, after which the new file went from F82E9 to 23CF92 and so on.
How do I strip the bytes from 49AFC to F823F and write them to a new file?.
I tried to implement it like this: I create an array of bytes and fill it with bytes from 49AFC to F823F, after which I write this array to a file.
But this approach is very rough and the program hangs up to 5 minutes while filling the array.
How to implement this robot correctly?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evhen, 2016-03-21
@EugeneP2

Read the file and immediately write to the files. No need to create any intermediate arrays.
If you need random access to a file, I recommend paying attention to the RandomAccessFile class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question