AYUDA CON ESTE ERROR-----------------------------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

private void writeFormFile(FormFileField formFile) throws IOException {

File file = formFile.getFile();

// create inputstream
currentFileName = file.getName();
System.out.println("CURRENT FILE "+ currentFileName);
BufferedInputStream in = new BufferedInputStream(new FileInputStream(file));

// write boundary
out.writeBytes(PREFIX);
out.writeBytes(boundary);
out.writeBytes(NEWLINE);

// write content header
out.writeBytes("Content-Disposition: form-data; name=\"" + formFile.getName() + "\"; filename=\"" + formFile.getURLEncodedUploadName() + "\"" + NEWLINE);
out.writeBytes("Content-Type: " + formFile.getContentType() + NEWLINE);
out.writeBytes(NEWLINE);

// write content
byte[] data = new byte[1024];
int len = 0;

while ((len = in.read(data, 0, data.length)) != -1) {
out.write(data, 0, len);

// update properties
bytesProcessed = bytesProcessed + len;
}

out.writeBytes(NEWLINE);
System.out.println("ANTES DEL FLUSH");
out.flush();
in.close();
}

El problema es que el error me lo esta mandando exactamente en el out.flush() por eso puse el system y es ahi hasta donde se queda mi programa al ejecutar mi boton de upload quien me puede ayudar .. nose por q no hace el flush .......

ERROR---

HTTPUploadTask - upload() - java.net.SocketException: Connection reset

Y MI METODO UPLOAD ES ESTE ---

public void upload() {

begin = System.currentTimeMillis();

try {

int maxImageSize = Parameters.getParameter(Parameters.MAX_IMAGE_SIZE, -1);

if (maxImageSize != -1) {
resizer = new Resize(this);
if (!resizeImages(maxImageSize)) {
return;
}
}

String zipFileName = Parameters.getParameter(Parameters.ZIP_FILE, null);

if (zipFileName != null) {
if (!createZipFile(zipFileName)) {
return;
}
}

// sets the default values to 0
init();

// needed for the progress dialog
uploading = true;

processStatus = localeManager.getString("connecting") + "....";

socket = netUtils.createSocket(uploadURL, proxyPasswordAuthentication);

out = new DataOutputStream(new BufferedOutputStream(socket.getOutputStream()));

// write the headers to the outputstream
writeHeaders();
writeFormInputFields(data.getFormInputFields());

processStatus = localeManager.getString("uploading") + "....";

writeFormFileFields(data.getFormFileFields());
writeFooters();

processStatus = localeManager.getString("waiting_for_response") + "....";

HTTPParser httpParser = new HTTPParser(socket.getInputStream(), "ISO-8859-1");

Logger.log("HTTPUploadTask", "upload()", httpParser.getStatusLine());

if (httpParser.getStatusCode() == 200) {
returnCode = SUCCESS;
statusCode = 200;

if (Parameters.getParameter(Parameters.SHOW_CUSTOM_ERROR_MESSAGES, false)) {
errorMessage = httpParser.getBody();

if (errorMessage != null && !errorMessage.trim().equals("")) {
returnCode = CUSTOM_ERROR;
}
}

} else {
returnCode = TECHNICAL_ERROR;
statusCode = httpParser.getStatusCode();
}

} catch (UnknownHostException uhe) {

Logger.log("HTTPUploadTask", "upload()", uhe.toString());

if (!abort) {
returnCode = TECHNICAL_ERROR;
}

finished = true;
worker.interrupt();

} catch (ConnectException ce) {

Logger.log("HTTPUploadTask", "upload()", ce.toString());

if (!abort) {
returnCode = CONNECTION_REFUSED;
}

finished = true;
worker.interrupt();

} catch (IOException ioe) {

Logger.log("HTTPUploadTask", "upload()", ioe.toString());

if (!abort) {
returnCode = TECHNICAL_ERROR;
}

finished = true;
worker.interrupt();

} catch (Throwable t) {

Logger.log("HTTPUploadTask", "upload()", t.toString());
returnCode = TECHNICAL_ERROR;

finished = true;
worker.interrupt();

} finally {

if (resizer != null) {
resizer.deleteTempDirectory();
}

if (out != null) {
try {
out.close();
} catch (IOException ioe) {
}
}

if (socket != null) {
try {
socket.close();
} catch (IOException ioe) {
}
}

// if a zip has been created delete it
if (zipFile != null) {
zipFile.delete();
}

finished = true;
}
}