I'm new in Java, and I have just a little experience in String manipulation. This is a quick problem to solve if you are a Java expert or at least have a considerable experience in it, but if you are a newbie(like me) this is an extremelly hard operation. I not asking you to solve the problem for me, but if you can point me a solution, or even indicate examples in manipulating bytes of a String. But if you have the algoritihm, I would be very happy if you share it with me and the other newbies in this community...
Let me see if I understand this, in the ArrayList you will store Strings of around 50 bytes, correct?
You must know that in Java, String may contain characters in different encodings (i.e ASCII, UTF-8, UTF-16, etc, etc, etc).
Therefore, the binary representation of the String characters could vary depending on the enconding. If your encoding is ASCII then in binary form most probably every byte would correspond to a character, but the same cannot be said of all other encodings. Also, it is important to highligh that the number of bytes required to store the characters of a String in particular enconding has nothing to do with the size in bytes of a String object if serialized.
That being said, in what encoding should your strings fit in 50 bytes chunks?
I ask this because spliting the string based on bytes might leave you with a chuck of bytes that has not sense in particular encoding.
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop