|
package fvhttpserver;
import java.io.*;
public class Impostazioni {
public int port;
private Impostazioni (int p, String b ) {
port = p;
basedir = b;
}
public static Impostazioni getImpostazioni() {
if(!f.exists()) {
try {
createFile();
}
try {
int p = 80;
while((tmp = dis.readLine()) != null) {
if(tmp.length()>= 5 && tmp.toLowerCase().substring(0, 5).equals("port:")) {
p = Integer. parseInt(tmp. substring(5 ));
}
if(tmp.length()>= 8 && tmp.toLowerCase().substring(0, 8).equals("basedir:")) {
b = tmp.substring(8);
}
}
dis.close();
return new Impostazioni(p, b);
System. out. println("Impossibile leggere nel file di configurazione!!\n " + ex. toString());
try {
createFile();
System. out. println("Impossibile creare ll file di configurazione!!\n " + ex. toString());
}
return new Impostazioni(80, "");
}
}
f.delete();
f.createNewFile();
out.print("port:" + port + "\n"
+ "basedir:" + basedir);
out.close();
Main.basedir = basedir;
}
f.delete();
f.createNewFile();
out.print("port:80\n"
+ "basedir:");
out.close();
}
}
|
|