在J2EE工程中,目前要将图片信息转成byte流发给JMS队列
代码如下:
FileInputStream in = null;
File f = new File ("pic1.jpg");
in = new FileInputStream(f);
byte []byteattachContent;
byteattachContent = new byte[(int)f.length()];
in.read(byteattachContent);
try
{
in.close();
}
catch(Exception ex)
{ex.printStackTrace(); }
//write content of second attachement
ByteArrayOutputStream outByteMsg = new ByteArrayOutputStream();
DataOutputStream sendMsg = new DataOutputStream(outByteMsg);
sendMsg.writeInt(byteattachContent.length);
sendMsg.write(byteattachContent);但是在接受客户端解析图片失败.请问用什么好的方法可以将图片传到目的地?ImageIO已尝试过,似乎不行
代码如下:
FileInputStream in = null;
File f = new File ("pic1.jpg");
in = new FileInputStream(f);
byte []byteattachContent;
byteattachContent = new byte[(int)f.length()];
in.read(byteattachContent);
try
{
in.close();
}
catch(Exception ex)
{ex.printStackTrace(); }
//write content of second attachement
ByteArrayOutputStream outByteMsg = new ByteArrayOutputStream();
DataOutputStream sendMsg = new DataOutputStream(outByteMsg);
sendMsg.writeInt(byteattachContent.length);
sendMsg.write(byteattachContent);但是在接受客户端解析图片失败.请问用什么好的方法可以将图片传到目的地?ImageIO已尝试过,似乎不行
sendMsg.write(byteattachContent,0,byteattachContent.length);