Reading bytestream and writing to file
pCurrently I have this implementation working reading from a bytestream
and writing out to file. I am wondering if this is particularly dangerous
or discouraged against, in the essence of time I'm unable to test all the
different implementations of this mechanism and this seems to be working.
Any advice would be greatly appreciated./p
precodeSharedByteArrayInputStream stream = (SharedByteArrayInputStream)
content; ArrayListlt;Bytegt; bites = new ArrayListlt;Bytegt;(); byte bite
= 0; while((bite=(byte) stream.read())!=-1){ bites.add(bite); } byte[]
bytes = new byte[bites.size()]; for(int x = 0; x lt; bites.size(); x++){
bytes[x] = (byte) bites.get(x); } String aloha = new String(bytes,
Charset.forName( ISO-8859-1 )); writer.append(aloha+\n); stream.close();
/code/pre pI know it looks silly but it works./p pThanks again for any
input/p
No comments:
Post a Comment