android使用imageview和HttpPost将图像发送到servlet

android使用imageview和HttpPost将图像发送到servlet,android,Android,我正在开发一个android应用程序,其中我使用ImageView通过摄像头捕捉图像 那么,如何使用httppost将imageview中捕获的图像作为多部分发送到Javaservlet呢 ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageView view = (ImageView)findViewById(R.id.imageView1);

我正在开发一个android应用程序,其中我使用ImageView通过摄像头捕捉图像

那么,如何使用httppost将imageview中捕获的图像作为多部分发送到Javaservlet呢

            ByteArrayOutputStream baos = new ByteArrayOutputStream();

            ImageView view = (ImageView)findViewById(R.id.imageView1);

            view.setDrawingCacheEnabled(true);

            view.buildDrawingCache();

            Bitmap bm = view.getDrawingCache();             

            bm.compress(Bitmap.CompressFormat.PNG, 100, baos);

            byte[] b = baos.toByteArray();
谢谢。

看看这里:

示例代码:


请参阅发布内容部分。

您的意思是
如何将字节数组b发送到服务器?
。是的。如何使用httppost或任何其他方法将bytearray b发送到服务器,然后使用servlet将图像保存到服务器上?您没有告诉servlet希望如何发送数据。那我们就帮不了你了。如果你想用HttpPost发送东西,那没关系。非常容易发送一个字节数组。如果你从这个带有android标签的网站上读到10页(50个线程),你可以找到的代码。
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
try {
    urlConnection.setDoOutput(true);
    urlConnection.setChunkedStreamingMode(0);

    OutputStream out = new BufferedOutputStream(urlConnection.getOutputStream());
    writeStream(out);

    InputStream in = new BufferedInputStream(urlConnection.getInputStream());
    readStream(in);
finally {
    urlConnection.disconnect();
}