import org.apache.commons.io.IOUtils;
Runnable revImageThread = new Runnable() {
public void run() {
int buf_size = 1024;
byte[] buffer = new byte[buf_size];
int len = 0;
try {
ss = new ServerSocket(40000);
} catch (IOException e) {
}
InputStream ins = null;
while (true) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
try {
s = ss.accept();
ins = s.getInputStream();
while ((len = ins.read(buffer, 0 , buf_size)) != -1) {
outStream.write(buffer, 0, len);
}
byte data[] = outStream.toByteArray();
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
if (!s.isClosed()) {
s.close();
}
} catch (IOException e) {
} finally {
IOUtils.closeQuietly(outStream);
IOUtils.closeQuietly(ins);
}
}
}
};
|