new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {
new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {
SharedByteArrayInputStream stream = (SharedByteArrayInputStream) content; ByteArrayOutputStream bOut = new ByteArrayOutputStream(); //Reading in chunks is better performance-wise than reading one byte at once. int r; byte[] buffer = new byte[32 * 1000]; //Read and write into the ByteArrayOutputStream while((r = stream.read(buffer) != -1){ bOut.write(buffer, 0, r); } String aloha = new String(bOut.toByteArray(), Charset.forName( "ISO-8859-1" )); writer.append(aloha+"\n"); stream.close();
FileOutputStream fileOutputStream = new FileOutputStream(filepath); SharedByteArrayInputStream stream = (SharedByteArrayInputStream) content; byte bite = 0; byte[] buffer = new byte[1024]; //here we're reading more than one byte at a time. while((bite=(byte) stream.read(buffer))!=-1){ //write to file output stream instead. fileOutputStream.write(buffer,0,bite); //don't append new line character. } stream.close(); //close the output stream if you're done. fileOutputStream.close();
// Get the message object from the folder in the // usual way, for example: MimeMessage msg = (MimeMessage)folder.getMessage(n); // Copy the message by writing into an byte array and // creating a new MimeMessage object based on the contents // of the byte array: ByteArrayOutputStream bos = new ByteArrayOutputStream(); msg.writeTo(bos); bos.close(); SharedByteArrayInputStream bis = new SharedByteArrayInputStream(bos.toByteArray()); MimeMessage cmsg = new MimeMessage(session, bis); bis.close(); // The cmsg object is disconnected from the server so // setFlags will have no effect (for example). Use // the original msg object for such operations. Use // the cmsg object to access the content of the message.
@Override public void dispose() { try { in.close(); } catch (IOException e) { //ignore exception during close } LifecycleUtil.dispose(in); try { message.clearBody(); } catch (JMSException e) { LOGGER.error("Error clearing JMS message body", e); } try { message.clearProperties(); } catch (JMSException e) { LOGGER.error("Error clearing JMS message properties", e); } content = null; }
new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {
new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {
new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {
new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {
new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {
new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {
new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {
new SharedByteArrayInputStream(bos.toByteArray()); parse(bis); bis.close(); saved = true; } catch (IOException ex) {