Reading a file into a byte array?



I need to read binary data of arbitrary length into a program,
manipulate the data, and then write the data to the network or to
another file. I know of two objects that might store this data:

byte[] (a byte array)
and
ByteArrayInputStream (which must be initialized with a byte[])

Now, the question is how do I get my data into byte[] in the first
place? I know how to read strings in:

public int ReadingMethod(String pathname) {
try {
BufferedReader reader = new BufferedReader(new
FileReader(pathname));
String readstring = new String();

while ((readstring = reader.readLine()) != null) {
etc.

But I don't know how to handle arbitrary binary data. Any thoughts on
how I can do this?

Thanks!

.



Relevant Pages

  • Re: Binary File I/O
    ... > sufficiently to know if binary data sequences can be manipulated. ... > can be manipulated as Array objects (with Unicode elements? ... are a range of bitwise operators in the language to manipulate the data ... String objects can also be used in this respect Each character can ...
    (microsoft.public.scripting.jscript)
  • How to intercept what HttpWebRequest sends?
    ... I'm currently thinking about a way how to intercept the binary data that ... HttpWebRequest sends over the network. ... like to have control over the header ...
    (microsoft.public.dotnet.framework)
  • Re: Transferring binary data to a function of a COM object
    ... > this value is truncated at the embedded null charaters. ... binary data, ... It works with DCOM too. ... Prev by Date: ...
    (microsoft.public.vc.atl)
  • How to serialize to binary data for TCP/IP communication
    ... I am searching a tutorial which shows me how I can serailia a C++ class to ... binary data to send it over the network and deserialze it at the receiver. ...
    (microsoft.public.dotnet.languages.vc)
  • Re: struct unpack newline
    ... has a problem reading the file correctly. ... There is _no_ correct way of splitting a file containing binary data in ... Peter ... Prev by Date: ...
    (comp.lang.python)

Loading