1
我有一個默認的Spring消息偵聽器正在運行。Spring JMS TextMessage寫入到PDF
當在onMessage擊中,它有作爲的TextMessage(NOT BytesMessage)
如何編寫成PDF文件?
我認爲有一些問題,下面我的代碼......所以將其寫入文件,但該PDF文檔無法打開......
if (message instanceof TextMessage) {
try {
//System.out.println(((TextMessage) message).getText());
TextMessage txtMessage = (TextMessage)message;
ByteArrayInputStream bais = new ByteArrayInputStream(txtMessage.getText().getBytes("UTF8"));
String outStr=bais.toString();
File newFile=new File("D:\\document.pdf");
FileOutputStream fos = new FileOutputStream(newFile);
int data;
while((data=bais.read())!=-1)
{
char ch = (char)data;
fos.write(ch);
}
fos.flush();
fos.close();
感謝您的任何建議