java - Stream closed showing up in play framework 1.2.5 -


i have application want write file using fileoutputstream

here's code, method patch

public static response patch() {     try {         system.out.println("patch");         system.out.println(request.contenttype);         string file = params.get("filename");         system.out.println("patch file: " + file);         map<string, header> mapoffset = request.headers;         (entry<string, header> entry : mapoffset.entryset()) {             system.out.println("header['" + entry.getkey() + "]: "                     + entry.getvalue().value());         }          header offsetparam = mapoffset.get("offset");         long offset = 0l;         if (offsetparam != null) {             offset = long.parselong(offsetparam.value());         }          inputstream input = request.body;         file f = new file(upload_dir + system.getproperty("file.separator")                 + file);          system.out.println("address: " + f.getabsolutepath());         system.out.println("offset: " + offset);         system.out.println("length: " + f.length());          filebasicupload(f, offset, input);          response respon = new response();         respon.status = ok;          return respon;     } catch (exception e) {         e.printstacktrace();         return null;     } } 

and write file

private static void filebasicupload(file f, long offset, inputstream input)         throws ioexception {     fileoutputstream output = null;     try {         int c = -1;         byte[] b = new byte[1024];         try {             output = new fileoutputstream(f, true);             while ((c = input.read(b)) != -1) {                 output.write(b, 0, c);             }         } catch (exception e) {             system.out.println("error: " + e.getmessage());         }     } {         output.close();     } } 

but when application called, stream closed error show @ while ((c = input.read(b)) != -1) line. don't know how error called. sorry poor english ,

i found answer. in application found

 public static response upload(file file){     system.out.println("appliaction.upload");     response = resumableupload.post();     return response; 

// render(response);
}

the parameter file, must delete, work!


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -