This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes OutputStream System.out to String BLOB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic
Author

OutputStream System.out to String BLOB

Imre Tokai
Ranch Hand

Joined: Jun 04, 2008
Posts: 130
Hello!


I have a piece of code:

where byteArray is a BLOB type.
This is working fine.

Instead of the output stream, i want to convert bytes to string. So, i need sg like StringOutputStrem.


What classes should i use and how?

Regards
Sivakumar Janardhanan
Ranch Hand

Joined: Dec 11, 2008
Posts: 30
I think you should use String class.String class has a lot of method.So you can able to convert bytearray to String.

you try this one:

Convert the byte array to a String using the constructor

String byteString = new String(byte[] bytes) ;

do the replacement

byteString = byteString.replace("bert|ernie" , "") ;

and convert back

byte [] newBytes = byteString.getBytes() ;

and then write it out :-)
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19672
    
  18

Imre, after a few months I would expect you knew to Use One Thread Per Question. This is the exact same question as this one.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38412
    
  23
Originally posted by Rob Prime:
Imre, after a few months I would expect you knew to Use One Thread Per Question. This is the exact same question as this one.
I hadn't noticed.

Closing thread.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: OutputStream System.out to String BLOB