Question

I am trying to get all the src (or SRC) URLs that appear in an array of bytes, however, I do not know how to implement the byte array. The code I have now extracts all parts of the HTML that begin with src= or SRC= and pulls out the correct items. However, how would the byte array play a role in this? The byte array is a sequence of chars that might contain src (or SRC) URLs, initialized from the contents of a URL. Furthermore, the string of vectors that is at the end of this function is supposed to contain all the src attributes found in data. I have a saveResource function that saves a resource in a file, as well as in a byte array which is also shown below.

How do I store the src urls that my program is pulling out into the byte array?

Was it helpful?

Solution

It looks like you're asking how to store a Vector<String> in a byte array. This sounds weird, so maybe I've interpreted it wrong.

  • Vectors are serializable. You can use an ObjectOutputStream to write them to an output stream.
  • ByteArrayOutputStream implements an OutputStream that writes to memory. It has a method toByteArray() that you can call to get its contents as a byte array.

That should be enough to solve this problem.

edit: maybe also some System.arraycopy if you need it to go in the data argument... again, weird.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top