📄 client.java
字号:
/* * Client.java * * Created on 24. oktober 2005, 21:07 * * To change this template, choose Tools | Options and locate the template under * the Source Creation and Management node. Right-click the template and choose * Open. You can then make changes to the template in the Source Editor. */package backup.client;import backup.client.*;import java.io.FileInputStream;import java.io.*;import java.util.*;import java.rmi.Naming;import javax.swing.*;import backup.server.Server;/** * * @author Kim Stenbo Nielsen */public class Client { private Server server; private static String serverAddress; private static String serverPort; String name; Gui gui; /** * Creates a new instance of Client */ public Client() { setLookAndFeel(); loadConfiguration(); connectToServer(); } public Client(String server, String port) { serverAddress = server; serverPort = port; setLookAndFeel(); connectToServer(); } private void loadConfiguration() { try { File config = new File("client.cfg"); if (config.exists()) { BufferedReader in = new BufferedReader(new FileReader(config)); serverAddress = in.readLine(); } else { System.out.print("Please enter the remote servers IP and RMI port number (eg. 172.24.37.21:1099):\n "); Scanner keyboard = new Scanner(System.in); serverAddress = keyboard.nextLine(); config.createNewFile(); FileWriter out = new FileWriter(config); out.write(serverAddress); out.flush(); out.close(); } } catch (Exception e) { e.printStackTrace(); } } private void setLookAndFeel() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } } public void connectToServer() { try { server = (Server) Naming.lookup("//" + serverAddress + ":" + serverPort + "/miniWebPACS_Backup"); System.out.println(": succes"); System.out.println(" - Starting up client GUI"); gui = new Gui(server); } catch (Exception e) { e.printStackTrace(); } } public static void main(String[] arg) throws Exception { System.out.println("\n**********************************************"); System.out.println("** Welcome to miniWebPACS Backup Client **"); System.out.println("**********************************************\n"); System.out.println("Initializing..."); if (arg.length == 0) { // no arguments are given - prompt the user!! new Client(); } else if (arg.length == 1) { // only the IP is given as an argument serverAddress = arg[0]; // TODO: CHECK the argument for validity!!! serverPort = "1099"; new Client(serverAddress, serverPort); } else { serverAddress = arg[0]; // TODO: CHECK the argumet for validity!!! serverPort = arg[1]; new Client(serverAddress, serverPort); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -