i have debug this application oos.write(buffer); this line makes the error i am using socket programming from connecting java and php.. this program send the image to php.
full code
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clientserverapplication;
import java.net.*;
import java.io.*;
public class ImageServer {
public static void main(String[] args) {
int port = 2035;
ServerSocket listenSock = null; //the listening server socket
Socket client = null; //the socket that will actually be used for communication
try {
listenSock = new ServerSocket(port);
System.out.println("Server setup and waiting for client connection ...");
while (true) {
client = listenSock.accept();
System.out.println("Client connection accepted.");
BufferedReader br =
new BufferedReader(new InputStreamReader(client.getInputStream()));
BufferedWriter bw =
new BufferedWriter(new OutputStreamWriter(client.getOutputStream()));
String line = "";
while ((line = br.readLine()) != null) {
if(line.equals("php"))
{
FileInputStream fis = new FileInputStream("/Users/ashida/test/Cross.jpg");
byte[] buffer = new byte[fis.available()];
// fis.read(buffer);
int count = 0;
ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream()) ;
//while ((count = fis.read(buffer)) >= 0) {
oos.write(buffer);
oos.close();
//}
bw.flush();
}
}
bw.close();
br.close();
client.close();
}
} catch (IOException ex) {
ex.printStackTrace();
//System.out.println("Did not accept connection: " + ex);
}
}
}