*/
protected void uploadWar(HttpServletRequest request, File war)
throws IOException {
war.delete();
ServletInputStream istream = null;
BufferedOutputStream ostream = null;
try {
istream = request.getInputStream();
ostream =
new BufferedOutputStream(new FileOutputStream(war), 1024);
byte buffer[] = new byte[1024];
while (true) {
int n = istream.read(buffer);
if (n < 0) {
break;
}
ostream.write(buffer, 0, n);
}
ostream.flush();
ostream.close();
ostream = null;
istream.close();
istream = null;
} catch (IOException e) {
war.delete();
throw e;
} finally {
if (ostream != null) {
try {
ostream.close();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
}
ostream = null;
}
if (istream != null) {
try {
istream.close();
} catch (Throwable t) {
ExceptionUtils.handleThrowable(t);
}
istream = null;
}