Hi all
I need to covert a byte array from a server to a image at client.
Folowing is the code
Server.java
public static byte[] getImageasByteArray()
{
// implementation goes here
}
public static void main(String args[])
{
ServerSocket sock = null;
Socket clientSocket = null;
PrintWriter pw = null;
try
{
sock = new ServerSocket(serverPort);
clientSocket = sock.accept();
pw = new PrintWriter(clientSocket.getOutputStream(), true);
// other codes goes here
pw.println(getImageasByteArray());
}
catch (Throwable e)
{
....
}
}
Does any one know a suitable code for the client side? I'm implement the client on j2me platform. Since I have at the client
InputStream is = sc.openInputStream();
DataInputStream dataInputStream = new DataInputStream(is);
Some how I need to get the byte array and convert it into image. Following is the normal string buffer case at client . How can I convert this back to image
StringBuffer results = new StringBuffer();
int inputChar;
while ((inputChar = dataInputStream.read()) != -1)
{
results.append((byte) inputChar);
}
is.close();
dataInputStream.close();
sc.close();
Please help me
Thabnk You