This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sending pdf files to IBM MQ

 
Joseph Siao
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to convert a pdf file to its binary contents so I can send it as a message to an IBM MQ Series. How can i convert pdf to its binary contents in java?
Is there other alternatives besides converting pdf to binary representation? String? Array of Strings?
Anyone? Thanks
 
Kyle Brown
author
Ranch Hand
Posts: 3892
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The easiest way to do this is probably to read the contents of the file with a FileInputStream and then write the contents into a ByteArrayOutputStream. You can then put the ByteArray into your message.
Kyle
 
Joseph Siao
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. =) can i convert the byte array to string? because i need to append control numbers before and after the pdf file.
 
Rufus BugleWeed
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What prevents -
1) write contol codes to byte array
2) write file inputstream to byte array
3) write control codes to byte array
4) send byte array
?
 
C. Nimo
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Additionally -
You could write your Strings with Message.setStringProperty() calls.
Nimo.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic