Android convert String to byte[] - take byte[] on pieces?

– Bombastic Oct 18 at 9:10 @Bombastic Use String. Substring(beginIndex,endIndex).getBytes() – AVD Oct 18 at 9:11 Actually I think that for converting specific part of string to byte. I need the opposite of that.

Get maybe first 200 chars in bye and concert them as string. – Bombastic Oct 18 at 9:16 @Bombastic - You can use the constructor of String class.Download.oracle.Com/javase/6/docs/api/java/lang/String. Html – AVD Oct 18 at 9:19.

Convert your byte array to Base64 string an then split it. After that in merge phase merge that strings then convert result to Base64. Or if you have memory limitations first split your byte array to some byte arrays byte origBytes = ...; //a loop for splitting bytes byte splittedBytes1 = ...; byte splittedBytes2 = ...; ... String strbytes1 = Base64.

EncodeBytes(splittedBytes1); String strbytes2 = Base64. EncodeBytes(splittedBytes2); ...

If you have to create a string, you require several times more memory than size of all bytes. Firstly, string is a character array, the character has size 2 bytes. Secondly, the String is an immutable object, so it's impossible to create it using an existing array, so to construct it the second copy of the character array will be created.

If memory consumption is vital, consider using CharSequence instead of String. Finally, use StringBuilder or StringWriter, e.g. : String writer = new StringWriter(); writer. Write(new String(byteArrayChunk1, "UTF-8")); ... writer.

Write(new String(byteArrayChunkN, "UTF-8")); String resultString = writer.toString(); UPDATE: Another option, much more better, I think: ByteArrayOutputStream baos = new ByteArrayOutputStream(); baos. Write(byteArrayChunk1); baos. Write(byteArrayChunkN); String resultString = baos.

ToString("UTF-8").

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions