Java Reference
In-Depth Information
L ISTING 6.4 Continued
ArrayList result = new ArrayList();
StringTokenizer st = new StringTokenizer(s,”;:”);
while (st.hasMoreTokens()) {
String w = st.nextToken();
result.add(w);
}
String[] a = new String[result.size()];
result.toArray(a);
return a;
}
/**
* It sends data to the client
*/
private void sendToClient(DataInputStream dis, String name){
System.out.println( header + “sendToClient. “ + name);
byte[] buffer = new byte[1024];
try {
int read =0;
while ((read = dis.read(buffer)) != -1) {
out.write(buffer, 0, read);
}
} catch (IOException e) {
System.out.println( header + “send data back to client: “+e);
}
}
/**
* Loads properties file
*/
private void loadProperties(){
try {
downloadPolicy = new Properties();
FileInputStream in = new FileInputStream(SERVER_DIR+PROPS_FILE_NAME);
downloadPolicy.load(in);
in.close();
}
catch (IOException ex) {
System.out.println( header + “loadProperties(): “+ex);
}
}
/**
Search WWH ::




Custom Search