Java: Where can I find extended files / libraries for working with files?

I am writing arbitrary byte arrays (fake virus signatures of 32 bytes) to arbitrary files, and I need code to overwrite a specific file taking into account the offset to the file. My specific question is: is there any source code / libraries that I can use to perform this specific task?

I also had a problem with Python file manipulation. I am looking for a set of functions that can kill a string, cut / copy / paste, etc. My assumptions are that these are extremely common tasks, and I could not find them in the Java API and Google search.

Sorry for the lack of RTFM; I did not come across any information, and I searched for a while.

+3
source share
5 answers

Perhaps you are looking for something like the RandomAccessFile class in the standard Java JDK. It supports reading and writing with some offset, as well as byte arrays.

+4
source

Java RandomAccessFileis exactly what you want.

It includes methods such as seek(long)that allow you to navigate to where you need to in the file. It also allows you to read and write at the same time.

+4
source

, Java . ,

  • , , Swing, Document. . java.nio.channels.FileChannel , . , java.io java.nio do.

  • Apache Commons Flatfile, , , . , . , , . .

+2

File/FileReader/FileWriter/BufferedReader? , , , , ....

, , , API , RTF-, .

cut/copy/past, , "", , "" .

0

, 32- - , java.io:)

, , , ? , - , , , .

public static void writeFauxVirusSignature(File file, byte[] bytes, long offset) {
    //open file
    //move to offset
    //write bytes
    //close file
}

:

  • -?
  • ?

I ask because clean, easy-to-read code will use Apache Commons lib, but large file entries in a highly sensitive environment will require the use of java.niolibraries

0
source

Source: https://habr.com/ru/post/1711284/


All Articles