Add openning functionnality to server

This commit is contained in:
Louis Royer 2020-01-21 11:32:01 +01:00
parent a4bb32bf44
commit 3a27d84690

View File

@ -1,14 +1,27 @@
package serverP2P;
import serverP2P.ServerManagementUDP;
import tools.Directories;
import java.util.Scanner;
public class ServerP2P {
private int port;
private String dataHomeDirectory;
public ServerP2P() {
Directories d = new Directories("P2P_JAVA_PROJECT_SERVER");
String os = System.getProperty("os.name");
port = 40000;
dataHomeDirectory = new Directories("P2P_JAVA_PROJECT_SERVER").getDataHomeDirectory();
dataHomeDirectory = d.getDataHomeDirectory();
System.out.println("Server will listen on port " + port + " and serve files from " + dataHomeDirectory);
if (os.equals("Linux")||os.equals("Mac")||os.equals("Mac OS X")) {
System.out.println("Do you want to open this directory? (y/N)");
Scanner scanner = new Scanner(System.in);
String resp = scanner.nextLine();
if (resp.equals("y") || resp.equals("Y")) {
System.out.println("Openning");
d.openDataHomeDirectory();
}
}
}
public static void main(String [] args) {
ServerP2P s = new ServerP2P();