//============================================================================== // copyright 1998 Fred's Friends, Inc. // This example code is made public domain by Fiends.com //============================================================================== import java.awt.*; import java.net.*; import java.io.*; class Loader { static final String EXECFILE = "DCdbm13.exe"; String text; // final result of an operation //--- constructors --- Loader(String action,String data){ URL path; try { path = new URL(DCourt.root.cgibin+"/"+EXECFILE+"?"+ "cfg="+DCourt.root.config+"&act="+action); text = operate(path,data); } catch (MalformedURLException e) {return;} } String operate(URL path,String send){ URLConnection con; PrintStream out; DataInputStream in; String msg,tmp; int size,ix; byte[] buf; size = (send==null?0:send.length()); try { con = path.openConnection(); con.setDoInput(true); con.setDoOutput(true); con.setUseCaches(false); con.setRequestProperty("content-type","text/plain"); con.setRequestProperty("content-length",""+size); } catch (IOException e) {return "Error: "+e;} try { out = new PrintStream(con.getOutputStream()); if (send!=null) out.print(send); out.flush(); out.close(); } catch (IOException e) {return "Error: "+e;} size = con.getContentLength(); if (size<1) return ""; try { in = new DataInputStream(con.getInputStream()); buf = new byte[size]; in.read(buf); msg = new String(buf); in.close(); return msg; } catch (IOException e) {return ("Error: "+e);} } }