I have written a small TCP client to retrieve various data. It works fine for text, but I have no clue how to implement image processing. At the moment, the incoming data is stored in an ArrayList<String>
:
public ArrayList<String> sendSelector(String selector, String host, int port) throws IOException {
socket = new Socket(host, port);
out = new PrintWriter(socket.getOutputStream(), true);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out.println(encodePercent(selector) + CRLF);
ArrayList<String> lines = new ArrayList();
String line;
while ((line = in.readLine()) != null) {
if (line.equals("."))
break;
lines.add(line);
}
out.close();
in.close();
socket.close();
return lines;
}
How can I create an Image
or BufferedImage
out of a GIF or JPEG stored in an ArrayList<String>
? (Or am I completely in the dark and have to use different data structures?)