Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

To Find Lines containing string in binary files  RSS feed

 
Murphy Tai
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need a program that will find a specific string in a binary file, and then create an output stream to display the lines containing the string in another binary file.
 
Paul Clapham
Sheriff
Posts: 22472
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You mean you want a program to find a sequence of bytes in a binary file? (The rest of the post I didn't understand because it was ambiguous.)
 
Murphy Tai
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it's like a list of fields containing data. The program must be able to locate (as paul said) a sequence of bytes) then opens an output stream, copies the fields (in this case, lines) containing the "findByte" data into a new output binary file.
 
Paul Clapham
Sheriff
Posts: 22472
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then the logic is the same as for text files. Read a "line", see if it contains the desired sequence of bytes, and if it does then write the "line" to the output file. Repeat until end of file.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!