Example usage for java.io BufferedReader readLine

List of usage examples for java.io BufferedReader readLine

Introduction

In this page you can find the example usage for java.io BufferedReader readLine.

Prototype

public String readLine() throws IOException 

Source Link

Document

Reads a line of text.

Usage

From source file:it.geosolutions.sfs.web.Start.java

public static void main(String[] args) {
    final Server jettyServer = new Server();

    try {/*from   w  w w . j a v a2s  .  c om*/
        SocketConnector conn = new SocketConnector();
        String portVariable = System.getProperty("jetty.port");
        int port = parsePort(portVariable);
        if (port <= 0)
            port = 8082;
        conn.setPort(port);
        conn.setAcceptQueueSize(100);
        conn.setMaxIdleTime(1000 * 60 * 60);
        conn.setSoLingerTime(-1);

        // Use this to set a limit on the number of threads used to respond requests
        // BoundedThreadPool tp = new BoundedThreadPool();
        // tp.setMinThreads(8);
        // tp.setMaxThreads(8);
        // conn.setThreadPool(tp);

        // SSL host name given ?
        String sslHost = System.getProperty("ssl.hostname");
        SslSocketConnector sslConn = null;
        //            if (sslHost!=null && sslHost.length()>0) {   
        //                Security.addProvider(new BouncyCastleProvider());
        //                sslConn = getSslSocketConnector(sslHost);
        //            }

        if (sslConn == null) {
            jettyServer.setConnectors(new Connector[] { conn });
        } else {
            conn.setConfidentialPort(sslConn.getPort());
            jettyServer.setConnectors(new Connector[] { conn, sslConn });
        }

        /*Constraint constraint = new Constraint();
        constraint.setName(Constraint.__BASIC_AUTH);;
        constraint.setRoles(new String[]{"user","admin","moderator"});
        constraint.setAuthenticate(true);
                 
        ConstraintMapping cm = new ConstraintMapping();
        cm.setConstraint(constraint);
        cm.setPathSpec("/*");
                
        SecurityHandler sh = new SecurityHandler();
        sh.setUserRealm(new HashUserRealm("MyRealm","/Users/jdeolive/realm.properties"));
        sh.setConstraintMappings(new ConstraintMapping[]{cm});
                
        WebAppContext wah = new WebAppContext(sh, null, null, null);*/
        WebAppContext wah = new WebAppContext();
        wah.setContextPath("/sfs");
        wah.setWar("src/main/webapp");

        jettyServer.setHandler(wah);
        wah.setTempDirectory(new File("target/work"));
        //this allows to send large SLD's from the styles form
        wah.getServletContext().getContextHandler().setMaxFormContentSize(1024 * 1024 * 2);

        String jettyConfigFile = System.getProperty("jetty.config.file");
        if (jettyConfigFile != null) {
            //                log.info("Loading Jetty config from file: " + jettyConfigFile);
            (new XmlConfiguration(new FileInputStream(jettyConfigFile))).configure(jettyServer);
        }

        jettyServer.start();

        /*
         * Reads from System.in looking for the string "stop\n" in order to gracefully terminate
         * the jetty server and shut down the JVM. This way we can invoke the shutdown hooks
         * while debugging in eclipse. Can't catch CTRL-C to emulate SIGINT as the eclipse
         * console is not propagating that event
         */
        Thread stopThread = new Thread() {
            @Override
            public void run() {
                BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
                String line;
                try {
                    while (true) {
                        line = reader.readLine();
                        if ("stop".equals(line)) {
                            jettyServer.stop();
                            System.exit(0);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                    System.exit(1);
                }
            }
        };
        stopThread.setDaemon(true);
        stopThread.run();

        // use this to test normal stop behaviour, that is, to check stuff that
        // need to be done on container shutdown (and yes, this will make 
        // jetty stop just after you started it...)
        // jettyServer.stop(); 
    } catch (Exception e) {
        //            log.log(Level.SEVERE, "Could not start the Jetty server: " + e.getMessage(), e);

        if (jettyServer != null) {
            try {
                jettyServer.stop();
            } catch (Exception e1) {
                //                    log.log(Level.SEVERE,
                //                        "Unable to stop the " + "Jetty server:" + e1.getMessage(), e1);
            }
        }
    }
}

From source file:DataLoader.java

public static void main(String[] args)
        throws IOException, ValidationException, LicenseException, JobExecutionAlreadyRunningException,
        JobRestartException, JobInstanceAlreadyCompleteException, JobParametersInvalidException {

    System.out.println(//w w  w . j  a  v a 2 s . c om
            "System is initialising. Please wait for a few seconds then type your queries below once you see the prompt (->)");

    C24.init().withLicence("/biz/c24/api/license-ads.dat");

    // Create our application context - assumes the Spring configuration is in the classpath in a file called spring-config.xml
    ApplicationContext context = new ClassPathXmlApplicationContext("spring-config.xml");

    // ========================================================================
    // DEMO
    // A simple command-line interface to allow us to query the GemFire regions
    // ========================================================================

    GemfireTemplate template = context.getBean(GemfireTemplate.class);

    BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));

    boolean writePrompt = true;

    try {
        while (true) {
            if (writePrompt) {
                System.out.print("-> ");
                System.out.flush();
                writePrompt = false;
            }
            if (br.ready()) {
                try {

                    String request = br.readLine();
                    System.out.println("Running: " + request);
                    SelectResults<Object> results = template.find(request);
                    System.out.println();
                    System.out.println("Result:");
                    for (Object result : results.asList()) {
                        System.out.println(result.toString());
                    }
                } catch (Exception ex) {
                    System.out.println("Error executing last command " + ex.getMessage());
                    //ex.printStackTrace();
                }

                writePrompt = true;

            } else {
                // Wait for a second and try again
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException ioEx) {
                    break;
                }
            }
        }
    } catch (IOException ioe) {
        // Write any exceptions to stderr
        System.err.print(ioe);
    }

}

From source file:org.wso2.charon3.samples.user.sample01.CreateUserSample.java

public static void main(String[] args) {
    try {/*  w  ww  .  j av a  2s .c  om*/
        String url = "http://localhost:8080/scim/v2/Users";
        URL obj = new URL(url);
        HttpURLConnection con = (HttpURLConnection) obj.openConnection();

        // Setting basic post request
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/scim+json");

        // Send post request
        con.setDoOutput(true);
        DataOutputStream wr = new DataOutputStream(con.getOutputStream());
        wr.writeBytes(createRequestBody);
        wr.flush();
        wr.close();

        int responseCode = con.getResponseCode();

        BufferedReader in;
        if (responseCode == HttpURLConnection.HTTP_CREATED) { // success
            in = new BufferedReader(new InputStreamReader(con.getInputStream()));
        } else {
            in = new BufferedReader(new InputStreamReader(con.getErrorStream()));
        }
        String inputLine;
        StringBuffer response = new StringBuffer();

        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();

        //printing result from response
        System.out.println("Response Code : " + responseCode);
        System.out.println("Response Message : " + con.getResponseMessage());
        System.out.println("Response Content : " + response.toString());

    } catch (ProtocolException e) {
        e.printStackTrace();
    } catch (MalformedURLException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:ArraySet.java

public static void main(String[] args) throws java.io.IOException {
    ArraySet set = new ArraySet();
    java.io.BufferedReader in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
    while (true) {
        System.out.print(set.size() + ":"); //OK
        for (Iterator it = set.iterator(); it.hasNext();) {
            System.out.print(" " + it.next()); //OK
        }/*w w  w  . j a  v a  2  s . c  o  m*/
        System.out.println(); //OK
        System.out.print("> "); //OK
        String cmd = in.readLine();
        if (cmd == null)
            break;
        cmd = cmd.trim();
        if (cmd.equals("")) {
            ;
        } else if (cmd.startsWith("+")) {
            set.add(cmd.substring(1));
        } else if (cmd.startsWith("-")) {
            set.remove(cmd.substring(1));
        } else if (cmd.startsWith("?")) {
            boolean ret = set.contains(cmd.substring(1));
            System.out.println("  " + ret); //OK
        } else {
            System.out.println("unrecognized command"); //OK
        }
    }
}

From source file:akori.AKORI.java

public static void main(String[] args) throws IOException, InterruptedException {
    System.out.println("esto es AKORI");

    URL = "http://www.mbauchile.cl";
    PATH = "E:\\NetBeansProjects\\AKORI\\";
    NAME = "mbauchile.png";
    // Extrar DOM tree

    Document doc = Jsoup.connect(URL).timeout(0).get();

    // The Firefox driver supports javascript 
    WebDriver driver = new FirefoxDriver();
    driver.manage().window().maximize();
    System.out.println(driver.manage().window().getSize().toString());
    System.out.println(driver.manage().window().getPosition().toString());
    int xmax = driver.manage().window().getSize().width;
    int ymax = driver.manage().window().getSize().height;

    // Go to the URL page
    driver.get(URL);/*from w  w  w .ja v a  2  s  . c  om*/

    File screen = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    FileUtils.copyFile(screen, new File(PATH + NAME));

    BufferedImage img = ImageIO.read(new File(PATH + NAME));
    //Graphics2D graph = img.createGraphics();

    BufferedImage img1 = new BufferedImage(xmax, ymax, BufferedImage.TYPE_INT_ARGB);
    Graphics2D graph1 = img.createGraphics();
    double[][] matrix = new double[ymax][xmax];
    BufferedReader in = new BufferedReader(new FileReader("et.txt"));
    String linea;
    double max = 0;
    graph1.drawImage(img, 0, 0, null);
    HashMap<String, Integer> lista = new HashMap<String, Integer>();
    int count = 0;
    for (int i = 0; (linea = in.readLine()) != null && i < 10000; ++i) {
        String[] datos = linea.split(",");
        int x = (int) Double.parseDouble(datos[0]);
        int y = (int) Double.parseDouble(datos[2]);
        long time = Double.valueOf(datos[4]).longValue();
        if (x >= xmax || y >= ymax)
            continue;
        if (time < 691215)
            continue;
        if (time > 705648)
            break;
        if (lista.containsKey(x + "," + y))
            lista.put(x + "," + y, lista.get(x + "," + y) + 1);
        else
            lista.put(x + "," + y, 1);
        ++count;
    }
    System.out.println(count);
    in.close();
    Iterator iter = lista.entrySet().iterator();
    Map.Entry e;
    for (String key : lista.keySet()) {
        Integer i = lista.get(key);
        if (max < i)
            max = i;
    }
    System.out.println(max);
    max = 0;
    while (iter.hasNext()) {
        e = (Map.Entry) iter.next();
        String xy = (String) e.getKey();
        String[] datos = xy.split(",");
        int x = Integer.parseInt(datos[0]);
        int y = Integer.parseInt(datos[1]);
        matrix[y][x] += (int) e.getValue();
        double aux;
        if ((aux = normalMatrix(matrix, y, x, ((int) e.getValue()) * 4)) > max) {
            max = aux;
        }
        //normalMatrix(matrix,x,y,20);
        if (matrix[y][x] > max)
            max = matrix[y][x];
    }
    int A, R, G, B, n;
    for (int i = 0; i < xmax; ++i) {
        for (int j = 0; j < ymax; ++j) {
            if (matrix[j][i] != 0) {
                n = (int) Math.round(matrix[j][i] * 100 / max);
                R = Math.round((255 * n) / 100);
                G = Math.round((255 * (100 - n)) / 100);
                B = 0;
                A = Math.round((255 * n) / 100);
                ;
                if (R > 255)
                    R = 255;
                if (R < 0)
                    R = 0;
                if (G > 255)
                    G = 255;
                if (G < 0)
                    G = 0;
                if (R < 50)
                    A = 0;
                graph1.setColor(new Color(R, G, B, A));
                graph1.fillOval(i, j, 1, 1);
            }
        }
    }
    //graph1.dispose();

    ImageIO.write(img, "png", new File("example.png"));
    System.out.println(max);

    graph1.setColor(Color.RED);
    // Extraer elementos
    Elements e1 = doc.body().getAllElements();
    int i = 1;
    ArrayList<String> tags = new ArrayList<String>();
    for (Element temp : e1) {

        if (tags.indexOf(temp.tagName()) == -1) {
            tags.add(temp.tagName());

            List<WebElement> query = driver.findElements(By.tagName(temp.tagName()));
            for (WebElement temp1 : query) {
                Point po = temp1.getLocation();
                Dimension d = temp1.getSize();
                if (d.width <= 0 || d.height <= 0 || po.x < 0 || po.y < 0)
                    continue;
                System.out.println(i + " " + temp.nodeName());
                System.out.println("  x: " + po.x + " y: " + po.y);
                System.out.println("  width: " + d.width + " height: " + d.height);
                graph1.draw(new Rectangle(po.x, po.y, d.width, d.height));
                ++i;
            }
        }
    }

    graph1.dispose();
    ImageIO.write(img, "png", new File(PATH + NAME));

    driver.quit();

}

From source file:edu.oregonstate.eecs.mcplan.domains.toy.WeinsteinLittman.java

public static void main(final String[] argv) throws NumberFormatException, IOException {
    final RandomGenerator rng = new MersenneTwister(42);
    final int nirrelevant = 2;

    while (true) {
        final Parameters params = new Parameters(nirrelevant);
        final Actions actions = new Actions(params);
        final FsssModel model = new FsssModel(rng, params);

        State s = model.initialState();
        while (!s.isTerminal()) {
            System.out.println(s);
            System.out.println("R(s): " + model.reward(s));
            actions.setState(s, 0);/*from   www  .ja  va  2 s  .  c  om*/
            final ArrayList<Action> action_list = Fn.takeAll(actions);
            for (int i = 0; i < action_list.size(); ++i) {
                System.out.println(i + ": " + action_list.get(i));
            }
            System.out.print(">>> ");
            final BufferedReader cin = new BufferedReader(new InputStreamReader(System.in));
            final int choice = Integer.parseInt(cin.readLine());
            final Action a = action_list.get(choice);
            System.out.println("R(s, a): " + model.reward(s, a));
            s = model.sampleTransition(s, a);
        }
        System.out.println("Terminal: " + s);
        System.out.println("R(s): " + model.reward(s));
        System.out.println("********************");
    }
}

From source file:pl.edu.amu.wmi.bank.Bank.java

public static void main(String[] args) throws InterruptedException, IOException {

    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    ApplicationContext context = new ClassPathXmlApplicationContext("Context.xml");

    SendPublicKeyService keySender = (SendPublicKeyService) context.getBean("sendPublicKeyToShopService");

    keySender.sendPublicKey();// w  ww . j ava 2s.c  om

    Accounts accounts = (Accounts) context.getBean("accounts");

    System.out.println(accounts);

    while (true) {
        System.out.println("Wcisnij cokolwiek zeby ponownie wyslac klucz");
        reader.readLine();
        keySender.sendPublicKey();
    }

}

From source file:com.google.oacurl.Login.java

public static void main(String[] args) throws Exception {
    LoginOptions options = new LoginOptions();
    try {//from   w  w  w  .  j a v a 2  s . c om
        options.parse(args);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        System.exit(-1);
    }

    if (options.isHelp()) {
        new HelpFormatter().printHelp(" ", options.getOptions());
        System.exit(0);
    }

    if (options.isInsecure()) {
        SSLSocketFactory.getSocketFactory().setHostnameVerifier(new AllowAllHostnameVerifier());
    }

    LoggingConfig.init(options.isVerbose());
    if (options.isWirelogVerbose()) {
        LoggingConfig.enableWireLog();
    }

    ServiceProviderDao serviceProviderDao = new ServiceProviderDao();
    ConsumerDao consumerDao = new ConsumerDao(options);
    AccessorDao accessorDao = new AccessorDao();

    String serviceProviderFileName = options.getServiceProviderFileName();
    if (serviceProviderFileName == null) {
        if (options.isBuzz()) {
            // Buzz has its own provider because it has a custom authorization URL
            serviceProviderFileName = "BUZZ";
        } else if (options.getVersion() == OAuthVersion.V2) {
            serviceProviderFileName = "GOOGLE_V2";
        } else {
            serviceProviderFileName = "GOOGLE";
        }
    }

    // We have a wee library of service provider properties files bundled into
    // the resources, so we set up the PropertiesProvider to search for them
    // if the file cannot be found.
    OAuthServiceProvider serviceProvider = serviceProviderDao.loadServiceProvider(
            new PropertiesProvider(serviceProviderFileName, ServiceProviderDao.class, "services/").get());
    OAuthConsumer consumer = consumerDao
            .loadConsumer(new PropertiesProvider(options.getConsumerFileName()).get(), serviceProvider);
    OAuthAccessor accessor = accessorDao.newAccessor(consumer);

    OAuthClient client = new OAuthClient(new HttpClient4());

    LoginCallbackServer callbackServer = null;

    boolean launchedBrowser = false;

    try {
        if (!options.isNoServer()) {
            callbackServer = new LoginCallbackServer(options);
            callbackServer.start();
        }

        String callbackUrl;
        if (options.getCallback() != null) {
            callbackUrl = options.getCallback();
        } else if (callbackServer != null) {
            callbackUrl = callbackServer.getCallbackUrl();
        } else {
            callbackUrl = null;
        }

        OAuthEngine engine;
        switch (options.getVersion()) {
        case V1:
            engine = new V1OAuthEngine();
            break;
        case V2:
            engine = new V2OAuthEngine();
            break;
        case WRAP:
            engine = new WrapOAuthEngine();
            break;
        default:
            throw new IllegalArgumentException("Unknown version: " + options.getVersion());
        }

        do {
            String authorizationUrl = engine.getAuthorizationUrl(client, accessor, options, callbackUrl);

            if (!options.isNoServer()) {
                callbackServer.setAuthorizationUrl(authorizationUrl);
            }

            if (!launchedBrowser) {
                String url = options.isDemo() ? callbackServer.getDemoUrl() : authorizationUrl;

                if (options.isNoBrowser()) {
                    System.out.println(url);
                    System.out.flush();
                } else {
                    launchBrowser(options, url);
                }

                launchedBrowser = true;
            }

            accessor.accessToken = null;

            logger.log(Level.INFO, "Waiting for verification token...");
            String verifier;
            if (options.isNoServer()) {
                System.out.print("Verification token: ");
                BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
                verifier = "";
                while (verifier.isEmpty()) {
                    String line = reader.readLine();
                    if (line == null) {
                        System.exit(-1);
                    }
                    verifier = line.trim();
                }
            } else {
                verifier = callbackServer.waitForVerifier(accessor, -1);
                if (verifier == null) {
                    System.err.println("Wait for verifier interrupted");
                    System.exit(-1);
                }
            }
            logger.log(Level.INFO, "Verification token received: " + verifier);

            boolean success = engine.getAccessToken(accessor, client, callbackUrl, verifier);

            if (success) {
                if (callbackServer != null) {
                    callbackServer.setTokenStatus(TokenStatus.VALID);
                }

                Properties loginProperties = new Properties();
                accessorDao.saveAccessor(accessor, loginProperties);
                consumerDao.saveConsumer(consumer, loginProperties);
                loginProperties.put("oauthVersion", options.getVersion().toString());
                new PropertiesProvider(options.getLoginFileName()).overwrite(loginProperties);
            } else {
                if (callbackServer != null) {
                    callbackServer.setTokenStatus(TokenStatus.INVALID);
                }
            }
        } while (options.isDemo());
    } catch (OAuthProblemException e) {
        OAuthUtil.printOAuthProblemException(e);
    } finally {
        if (callbackServer != null) {
            callbackServer.stop();
        }
    }
}

From source file:keepassj.cli.KeepassjCli.java

/**
 * @param args the command line arguments
 * @throws org.apache.commons.cli.ParseException
 * @throws java.io.IOException//w  w  w  .  ja  va 2  s  . c om
 */
public static void main(String[] args) throws ParseException, IOException {
    Options options = KeepassjCli.getOptions();
    CommandLineParser parser = new DefaultParser();
    CommandLine cmd = parser.parse(options, args);
    if (!KeepassjCli.validateOptions(cmd)) {
        HelpFormatter help = new HelpFormatter();
        help.printHelp("Usage: java -jar KeepassjCli -f dbfile [options]", options);
    } else {
        String password;
        if (cmd.hasOption('p')) {
            password = cmd.getOptionValue('p');
        } else {
            Console console = System.console();
            char[] hiddenString = console.readPassword("Enter password for %s\n", cmd.getOptionValue('f'));
            password = String.valueOf(hiddenString);
        }
        KeepassjCli instance = new KeepassjCli(cmd.getOptionValue('f'), password, cmd.getOptionValue('k'));
        System.out.println("Description:" + instance.db.getDescription());
        PwGroup rootGroup = instance.db.getRootGroup();
        System.out.println(String.valueOf(rootGroup.GetEntriesCount(true)) + " entries");
        if (cmd.hasOption('l')) {
            instance.printEntries(rootGroup.GetEntries(true), false);
        } else if (cmd.hasOption('s')) {
            PwObjectList<PwEntry> results = instance.search(cmd.getOptionValue('s'));
            System.out.println("Found " + results.getUCount() + " results for:" + cmd.getOptionValue('s'));
            instance.printEntries(results, false);
        } else if (cmd.hasOption('i')) {
            System.out.println("Entering interactive mode.");
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
            String input = null;
            PwObjectList<PwEntry> results = null;
            while (!"\\q".equals(input)) {
                if (results != null) {
                    System.out.println("Would you like to view a specific entry? y/n");
                    input = bufferedReader.readLine();
                    if ("y".equalsIgnoreCase(input)) {
                        System.out.print("Enter the title number:");
                        input = bufferedReader.readLine();
                        instance.printCompleteEntry(results.GetAt(Integer.parseInt(input) - 1)); // Since humans start counting at 1
                    }
                    results = null;
                    System.out.println();
                } else {
                    System.out.print("Enter something to search for (or \\q to quit):");
                    input = bufferedReader.readLine();
                    if (!"\\q".equalsIgnoreCase(input)) {
                        results = instance.search(input);
                        instance.printEntries(results, true);
                    }
                }
            }
        }

        // Close before exit
        instance.db.Close();
    }
}

From source file:edu.mit.fss.examples.ISSFederate.java

/**
 * The main method. This configures the Orekit data path, creates the 
 * ISS federate objects and launches the associated graphical user 
 * interface.//from  ww  w.  j a v  a2s.  c  o m
 *
 * @param args the arguments
 * @throws RTIexception the RTI exception
 * @throws URISyntaxException 
 */
public static void main(String[] args) throws RTIexception, URISyntaxException {
    BasicConfigurator.configure();

    boolean headless = false;

    logger.debug("Setting Orekit data path.");
    System.setProperty(DataProvidersManager.OREKIT_DATA_PATH,
            new File(ISSFederate.class.getResource("/orekit-data.zip").toURI()).getAbsolutePath());

    logger.trace("Creating federate instance.");
    final ISSFederate federate = new ISSFederate();

    logger.trace("Setting minimum step duration and time step.");
    long timeStep = 60 * 1000, minimumStepDuration = 100;
    federate.setMinimumStepDuration(minimumStepDuration);
    federate.setTimeStep(timeStep);

    try {
        logger.debug("Loading TLE data from file.");
        BufferedReader br = new BufferedReader(new InputStreamReader(
                federate.getClass().getClassLoader().getResourceAsStream("edu/mit/fss/examples/data.tle")));

        final SpaceSystem satellite;
        final SurfaceSystem station1, station2, station3;

        while (br.ready()) {
            if (br.readLine().matches(".*ISS.*")) {
                logger.debug("Found ISS data.");

                logger.trace("Adding FSS supplier space system.");
                satellite = new SpaceSystem("FSS Supplier", new TLE(br.readLine(), br.readLine()), 5123e3);
                federate.addObject(satellite);

                logger.trace("Adding Keio ground station.");
                station1 = new SurfaceSystem("Keio",
                        new GeodeticPoint(FastMath.toRadians(35.551929), FastMath.toRadians(139.647119), 300),
                        satellite.getState().getDate(), 5123e3, 5);
                federate.addObject(station1);

                logger.trace("Adding SkolTech ground station.");
                station2 = new SurfaceSystem("SkolTech",
                        new GeodeticPoint(FastMath.toRadians(55.698679), FastMath.toRadians(37.571994), 200),
                        satellite.getState().getDate(), 5123e3, 5);
                federate.addObject(station2);

                logger.trace("Adding MIT ground station.");
                station3 = new SurfaceSystem("MIT",
                        new GeodeticPoint(FastMath.toRadians(42.360184), FastMath.toRadians(-71.093742), 100),
                        satellite.getState().getDate(), 5123e3, 5);
                federate.addObject(station3);

                try {
                    logger.trace("Setting inital time.");
                    federate.setInitialTime(
                            satellite.getInitialState().getDate().toDate(TimeScalesFactory.getUTC()).getTime());
                } catch (IllegalArgumentException | OrekitException e) {
                    logger.error(e.getMessage());
                    e.printStackTrace();
                }

                if (!headless) {
                    logger.debug("Launching the graphical user interface.");
                    SwingUtilities.invokeAndWait(new Runnable() {
                        @Override
                        public void run() {
                            MemberFrame frame = new MemberFrame(federate,
                                    new MultiComponentPanel(
                                            Arrays.asList(new SpaceSystemPanel(federate, satellite),
                                                    new SurfaceSystemPanel(federate, station1),
                                                    new SurfaceSystemPanel(federate, station2),
                                                    new SurfaceSystemPanel(federate, station3))));
                            frame.pack();
                            frame.setVisible(true);
                        }
                    });
                }

                break;
            }
        }
        br.close();
    } catch (InvocationTargetException | InterruptedException | OrekitException | IOException e) {
        e.printStackTrace();
        logger.fatal(e);
    }

    logger.trace("Setting federate name, type, and FOM path.");
    federate.getConnection().setFederateName("ISS");
    federate.getConnection().setFederateType("FSS Supplier");
    federate.getConnection().setFederationName("FSS");
    federate.getConnection().setFomPath(
            new File(federate.getClass().getClassLoader().getResource("edu/mit/fss/hla/fss.xml").toURI())
                    .getAbsolutePath());
    federate.getConnection().setOfflineMode(false);
    federate.connect();

    if (headless) {
        federate.setMinimumStepDuration(10);
        federate.initialize();
        federate.run();
    }
}