Java Reference
In-Depth Information
bytes = new byte[128];
}
out.println("</pre></body></html>");
out.close();
}
private void displayParams(ServletOutputStream out)
throws java.io.IOException{
for (Enumeration e = params.keys();e.hasMoreElements();) {
String key = (String)e.nextElement();
out.println(" "+key+" = "+params.get(key));
}
}
private void updateParams(Hashtable header){
for (Enumeration e = header.keys();e.hasMoreElements();) {
String key = (String)e.nextElement();
params.put(key,header.get(key));
}
}
private String getParameter(ServletInputStream in)
throws java.io.IOException{
byte[] bytes = new byte[128];
in.readLine(bytes,0,bytes.length);
return new String(bytes);
}
private String getBoundary(String contentType){
int bStart = contentType.indexOf("boundary=")+"boundary=".length();
return "" + CR + LF + "--" + contentType.substring(bStart);
}
private void savePayload(Hashtable params,BufferedInputStream is)
throws java.io.IOException{
int c;
PushbackInputStream input = new PushbackInputStream(is,128);
ByteArrayOutputStream out = new ByteArrayOutputStream();
while ( (c=read(input,boundary)) >= 0 )out.write( c );
int id = Integer.parseInt((String)params.get("ID"));
saveBlob(id,(String)params.get("filename"),out.toByteArray());
out.close();
}
private int read( PushbackInputStream input, String boundary )
throws IOException
{
StringBuffer buffer = new StringBuffer();
Search WWH ::




Custom Search