Java Reference
In-Depth Information
L ISTING 6.2 Continued
6
/**
* transform a fully qual. class name in a simpler name
*/
protected String getCacheClassFileName(String className) {
String result = className;
if (className.indexOf('.')!=-1)
result =className.substring(className.lastIndexOf('.')+1);
return result;
}
/**
* Loads properties file
*/
private void loadProperties(){
try {
appHelperSettings = new Properties();
FileInputStream in = new FileInputStream(CLIENT_DIR+PROPS_FILE_NAME);
appHelperSettings.load(in);
launchClassName = appHelperSettings.getProperty(“launchClass”,
DEFAULT_MAIN_CLASS_NAME);
in.close();
}
catch (IOException ex) {
System.out.println(“ApplicationHelper- loadProperties(): “+ex);
}
}
/**
* this method downloads and caches a file, taking advantage of the GET
command
*
*/
public File getRemoteFile(String serverFilename, boolean isClass) throws
IOException {
out.writeChar('g');
out.writeUTF(serverFilename);
int size = in.readInt();
byte[] resBytes = new byte[size];
in.readFully(resBytes);
if (resBytes.length!=0) {
String cacheName = serverFilename;
if (isClass)
cacheName += “.class”;
Search WWH ::




Custom Search