Example usage for java.util Properties getProperty

List of usage examples for java.util Properties getProperty

Introduction

In this page you can find the example usage for java.util Properties getProperty.

Prototype

public String getProperty(String key) 

Source Link

Document

Searches for the property with the specified key in this property list.

Usage

From source file:com.cloud.sample.UserCloudAPIExecutor.java

public static void main(String[] args) {
    // Host//from   w  w  w .j  a  va  2  s  . co  m
    String host = null;

    // Fully qualified URL with http(s)://host:port
    String apiUrl = null;

    // ApiKey and secretKey as given by your CloudStack vendor
    String apiKey = null;
    String secretKey = null;

    try {
        Properties prop = new Properties();
        prop.load(new FileInputStream("usercloud.properties"));

        // host
        host = prop.getProperty("host");
        if (host == null) {
            System.out.println(
                    "Please specify a valid host in the format of http(s)://:/client/api in your usercloud.properties file.");
        }

        // apiUrl
        apiUrl = prop.getProperty("apiUrl");
        if (apiUrl == null) {
            System.out.println(
                    "Please specify a valid API URL in the format of command=&param1=&param2=... in your usercloud.properties file.");
        }

        // apiKey
        apiKey = prop.getProperty("apiKey");
        if (apiKey == null) {
            System.out.println(
                    "Please specify your API Key as provided by your CloudStack vendor in your usercloud.properties file.");
        }

        // secretKey
        secretKey = prop.getProperty("secretKey");
        if (secretKey == null) {
            System.out.println(
                    "Please specify your secret Key as provided by your CloudStack vendor in your usercloud.properties file.");
        }

        if (apiUrl == null || apiKey == null || secretKey == null) {
            return;
        }

        System.out.println("Constructing API call to host = '" + host + "' with API command = '" + apiUrl
                + "' using apiKey = '" + apiKey + "' and secretKey = '" + secretKey + "'");

        // Step 1: Make sure your APIKey is URL encoded
        String encodedApiKey = URLEncoder.encode(apiKey, "UTF-8");

        // Step 2: URL encode each parameter value, then sort the parameters and apiKey in
        // alphabetical order, and then toLowerCase all the parameters, parameter values and apiKey.
        // Please note that if any parameters with a '&' as a value will cause this test client to fail since we are using
        // '&' to delimit
        // the string
        List<String> sortedParams = new ArrayList<String>();
        sortedParams.add("apikey=" + encodedApiKey.toLowerCase());
        StringTokenizer st = new StringTokenizer(apiUrl, "&");
        String url = null;
        boolean first = true;
        while (st.hasMoreTokens()) {
            String paramValue = st.nextToken();
            String param = paramValue.substring(0, paramValue.indexOf("="));
            String value = URLEncoder
                    .encode(paramValue.substring(paramValue.indexOf("=") + 1, paramValue.length()), "UTF-8");
            if (first) {
                url = param + "=" + value;
                first = false;
            } else {
                url = url + "&" + param + "=" + value;
            }
            sortedParams.add(param.toLowerCase() + "=" + value.toLowerCase());
        }
        Collections.sort(sortedParams);

        System.out.println("Sorted Parameters: " + sortedParams);

        // Step 3: Construct the sorted URL and sign and URL encode the sorted URL with your secret key
        String sortedUrl = null;
        first = true;
        for (String param : sortedParams) {
            if (first) {
                sortedUrl = param;
                first = false;
            } else {
                sortedUrl = sortedUrl + "&" + param;
            }
        }
        System.out.println("sorted URL : " + sortedUrl);
        String encodedSignature = signRequest(sortedUrl, secretKey);

        // Step 4: Construct the final URL we want to send to the CloudStack Management Server
        // Final result should look like:
        // http(s)://://client/api?&apiKey=&signature=
        String finalUrl = host + "?" + url + "&apiKey=" + apiKey + "&signature=" + encodedSignature;
        System.out.println("final URL : " + finalUrl);

        // Step 5: Perform a HTTP GET on this URL to execute the command
        HttpClient client = new HttpClient();
        HttpMethod method = new GetMethod(finalUrl);
        int responseCode = client.executeMethod(method);
        if (responseCode == 200) {
            // SUCCESS!
            System.out.println("Successfully executed command");
        } else {
            // FAILED!
            System.out.println("Unable to execute command with response code: " + responseCode);
        }

    } catch (Throwable t) {
        System.out.println(t);
    }
}

From source file:se.vgregion.portal.cs.util.CryptoUtilImpl.java

/**
 * Main method used for creating initial key file.
 * //from  w w  w .  j a v  a 2  s .  co m
 * @param args
 *            - not used
 */
public static void main(String[] args) {
    final String keyFile = "./howto.key";
    final String pwdFile = "./howto.properties";

    CryptoUtilImpl cryptoUtils = new CryptoUtilImpl();
    cryptoUtils.setKeyFile(new File(keyFile));

    String clearPwd = "my_cleartext_pwd";

    Properties p1 = new Properties();
    Writer w = null;
    try {
        p1.put("user", "liferay");
        String encryptedPwd = cryptoUtils.encrypt(clearPwd);
        p1.put("pwd", encryptedPwd);
        w = new FileWriter(pwdFile);
        p1.store(w, "");
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        if (w != null) {
            try {
                w.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    // ==================
    Properties p2 = new Properties();
    Reader r = null;
    try {
        r = new FileReader(pwdFile);
        p2.load(r);
        String encryptedPwd = p2.getProperty("pwd");
        System.out.println(encryptedPwd);
        System.out.println(cryptoUtils.decrypt(encryptedPwd));
    } catch (FileNotFoundException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (GeneralSecurityException e) {
        e.printStackTrace();
    } finally {
        if (r != null) {
            try {
                r.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

From source file:edu.indiana.d2i.sloan.internal.DeleteVMSimulator.java

public static void main(String[] args) {
    DeleteVMSimulator simulator = new DeleteVMSimulator();

    CommandLineParser parser = new PosixParser();

    try {/* w  ww  .j a  va2s  .c o m*/
        CommandLine line = simulator.parseCommandLine(parser, args);
        String wdir = line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.WORKING_DIR));

        if (!HypervisorCmdSimulator.resourceExist(wdir)) {
            logger.error(String.format("Cannot find VM working dir: %s", wdir));
            System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_EXIST));
        }

        Properties prop = new Properties();
        String filename = HypervisorCmdSimulator.cleanPath(wdir) + HypervisorCmdSimulator.VM_INFO_FILE_NAME;

        prop.load(new FileInputStream(new File(filename)));

        // cannot delete VM when it is not shutdown
        VMState currentState = VMState.valueOf(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_STATE)));

        if (!currentState.equals(VMState.SHUTDOWN)) {
            logger.error("Cannot perform delete when VM is not shutdown");
            System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_SHUTDOWN));
        }

        // delete working directory
        FileUtils.deleteDirectory(new File(wdir));

        // success
        System.exit(0);

    } catch (ParseException e) {
        logger.error(String.format("Cannot parse input arguments: %s%n, expected:%n%s",
                StringUtils.join(args, " "), simulator.getUsage(100, "", 5, 5, "")));

        System.exit(ERROR_CODE.get(ERROR_STATE.INVALID_INPUT_ARGS));
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        System.exit(ERROR_CODE.get(ERROR_STATE.IO_ERR));
    }

}

From source file:PropDemoDef.java

public static void main(String args[]) {
    Properties defList = new Properties();
    defList.put("Florida", "Tallahassee");
    defList.put("Wisconsin", "Madison");

    Properties capitals = new Properties(defList);

    capitals.put("Illinois", "Springfield");
    capitals.put("Missouri", "Jefferson City");
    capitals.put("Washington", "Olympia");
    capitals.put("California", "Sacramento");
    capitals.put("Indiana", "Indianapolis");

    Set states = capitals.keySet();

    for (Object name : states)
        System.out.println(name + " / " + capitals.getProperty((String) name));

    String str = capitals.getProperty("Florida");
    System.out.println("The capital of Florida is " + str + ".");
}

From source file:org.excalibur.benchmark.test.EC2InstancesBenchmark.java

public static void main(String[] args) throws IOException {
    final String benchmark = "sp";
    final String outputDir = "/home/alessandro/excalibur/source/services/benchmarks/ec2/";

    final String[] scripts = {
            readLines(getDefaultClassLoader()
                    .getResourceAsStream("org/excalibur/service/deployment/resource/script/iperf3.sh")),
            readLines(getDefaultClassLoader()
                    .getResourceAsStream("org/excalibur/service/deployment/resource/script/linkpack.sh")),
            readLines(getDefaultClassLoader().getResourceAsStream(
                    "org/excalibur/service/deployment/resource/script/benchmarks/run_linpack_xeon64.sh")), };

    final String[] instanceTypes = { "c3.8xlarge", "r3.large", "r3.xlarge", "r3.2xlarge", "i2.xlarge" };

    final String privateKeyMaterial = IOUtils2
            .readLines(new File(SystemUtils2.getUserDirectory(), "/.ec2/leite.pem"));
    final File sshKey = new File(SystemUtils2.getUserDirectory(), "/.ec2/leite.pem");
    Properties properties = Properties2
            .load(getDefaultClassLoader().getResourceAsStream("aws-config.properties"));

    final LoginCredentials loginCredentials = new LoginCredentials.Builder()
            .identity(properties.getProperty("aws.access.key"))
            .credential(properties.getProperty("aws.secret.key")).credentialName("leite").build();

    final UserProviderCredentials userProviderCredentials = new UserProviderCredentials()
            .setLoginCredentials(loginCredentials)
            .setRegion(new Region("us-east-1").setEndpoint("https://ec2.us-east-1.amazonaws.com"));

    final EC2 ec2 = new EC2(userProviderCredentials);

    List<Callable<Void>> tasks = Lists.newArrayList();

    for (final String instanceType : instanceTypes) {
        tasks.add(new Callable<Void>() {
            @Override//w  w w.  j  a v a 2 s  .  c  o m
            public Void call() throws Exception {
                InstanceTemplate template = new InstanceTemplate().setImageId("ami-864d84ee")
                        .setInstanceType(InstanceType.valueOf(instanceType)).setKeyName("leite")
                        .setLoginCredentials(
                                loginCredentials.toBuilder().privateKey(privateKeyMaterial).build())
                        .setGroup(new org.excalibur.core.cloud.api.Placement().setZone("us-east-1a")) //.setGroupName("iperf-bench")
                        .setMinCount(1).setMaxCount(1)
                        .setInstanceName(String.format("%s-%s", instanceType, benchmark))
                        .setRegion(userProviderCredentials.getRegion()).setTags(Tags
                                .newTags(new org.excalibur.core.cloud.api.domain.Tag("benchmark", benchmark)));

                final Instances instances = ec2.createInstances(template);

                for (VirtualMachine instance : instances) {
                    Preconditions.checkState(
                            !Strings.isNullOrEmpty(instance.getConfiguration().getPlatformUserName()));
                    Preconditions.checkState(
                            !Strings.isNullOrEmpty(instance.getConfiguration().getPublicIpAddress()));

                    HostAndPort hostAndPort = fromParts(instance.getConfiguration().getPublicIpAddress(), 22);

                    LoginCredentials sshCredentials = new LoginCredentials.Builder().authenticateAsSudo(true)
                            .privateKey(sshKey).user(instance.getConfiguration().getPlatformUserName()).build();

                    SshClient client = SshClientFactory.defaultSshClientFactory().create(hostAndPort,
                            sshCredentials);
                    client.connect();

                    try {
                        for (int i = 0; i < scripts.length; i++) {
                            ExecutableResponse response = client.execute(scripts[i]);
                            Files.write(response.getOutput().getBytes(), new File(outputDir,
                                    String.format("%s-%s.output.txt", template.getInstanceName(), i)));
                            LOG.info(
                                    "Executed the script [{}] with exit code [{}], error [{}], and output [{}] ",
                                    new Object[] { scripts[i], String.valueOf(response.getExitStatus()),
                                            response.getError(), response.getOutput() });
                        }
                    } finally {
                        client.disconnect();
                    }

                    ec2.terminateInstance(instance);
                }
                return null;
            }
        });
    }

    ListeningExecutorService executor = DynamicExecutors
            .newListeningDynamicScalingThreadPool("benchmark-instances-thread-%d");

    Futures2.invokeAllAndShutdownWhenFinish(tasks, executor);

    ec2.close();
}

From source file:edu.indiana.d2i.sloan.internal.StopVMSimulator.java

public static void main(String[] args) {
    StopVMSimulator simulator = new StopVMSimulator();

    CommandLineParser parser = new PosixParser();

    try {// w w w  .  ja v  a  2  s . co m
        CommandLine line = simulator.parseCommandLine(parser, args);
        String wdir = line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.WORKING_DIR));

        if (!HypervisorCmdSimulator.resourceExist(wdir)) {
            logger.error(String.format("Cannot find VM working dir: %s", wdir));
            System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_EXIST));
        }

        Properties prop = new Properties();
        String filename = HypervisorCmdSimulator.cleanPath(wdir) + HypervisorCmdSimulator.VM_INFO_FILE_NAME;

        prop.load(new FileInputStream(new File(filename)));

        // cannot stop VM when it is not running
        VMState currentState = VMState.valueOf(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_STATE)));

        if (!currentState.equals(VMState.RUNNING)) {
            logger.error("Cannot perform stop when VM is not running");
            System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_RUNNING));
        }

        // stop VM
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            logger.error(e.getMessage());
        }

        // update VM status file, i.e. set state to shutdown
        prop.put(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_STATE), VMState.SHUTDOWN.toString());

        // save VM state file back
        prop.store(new FileOutputStream(new File(filename)), "");

        // success
        System.exit(0);

    } catch (ParseException e) {
        logger.error(String.format("Cannot parse input arguments: %s%n, expected:%n%s",
                StringUtils.join(args, " "), simulator.getUsage(100, "", 5, 5, "")));

        System.exit(ERROR_CODE.get(ERROR_STATE.INVALID_INPUT_ARGS));
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        System.exit(ERROR_CODE.get(ERROR_STATE.IO_ERR));
    }

}

From source file:com.image32.demo.simpleapi.SimpleApiDemo.java

final public static void main(String[] args) {
    me = new SimpleApiDemo();
    me.contentHandlers = new ContentHandler();

    //load configurations
    try {//from   w  w  w .j a va2  s.c o  m
        Properties prop = new Properties();
        InputStream input = SimpleApiDemo.class.getResourceAsStream("/demoConfig.properties");

        // load a properties file
        prop.load(input);
        image32ApiClientId = prop.getProperty("image32ApiClientId");
        image32ApiSecrect = prop.getProperty("image32ApiSecrect");
        image32ApiAuthUrl = prop.getProperty("image32ApiAuthUrl");
        image32ApiGetStudiesUrl = prop.getProperty("image32ApiGetStudiesUrl");
        demoDataFile = prop.getProperty("demoDataFile");
        input.close();
    } catch (Exception ex) {
        logger.info("No configuration found.");
        System.exit(1);
    }

    // test port availability
    while (!checkPortAvailablity(port)) {
        if (port > 8090) {
            logger.info("Port is not available. Exiting...");
            System.exit(1);
        }
        port++;
    }
    ;

    // run server
    server = new Server(port);
    HashSessionIdManager hashSessionIdManager = new HashSessionIdManager();
    server.setSessionIdManager(hashSessionIdManager);

    WebAppContext homecontext = new WebAppContext();
    homecontext.setContextPath("/home");
    ResourceCollection resources = new ResourceCollection(new String[] { "site" });
    homecontext.setBaseResource(resources);

    HashSessionManager manager = new HashSessionManager();
    manager.setSecureCookies(true);
    SessionHandler sessionHandler = new SessionHandler(manager);

    sessionHandler.setHandler(me.contentHandlers);

    ContextHandler context = new ContextHandler();
    context.setContextPath("/app");
    context.setResourceBase(".");
    context.setClassLoader(Thread.currentThread().getContextClassLoader());
    context.setHandler(sessionHandler);

    HandlerList handlers = new HandlerList();
    handlers.setHandlers(new Handler[] { homecontext, context });

    server.setHandler(handlers);

    try {
        server.start();
        logger.info("Server started on port " + port);
        logger.info("Please access this demo from browser with this url: http://localhost:" + port);

        if (Desktop.isDesktopSupported())
            Desktop.getDesktop().browse(new URI("http://localhost:" + port + "/home"));

        server.join();
    } catch (Exception exception) {
        logger.error(exception.getMessage());
    }
    System.exit(1);
}

From source file:GetDBInfo.java

public static void main(String[] args) {
    Connection c = null; // The JDBC connection to the database server
    try {//www  .  ja  v a  2s .c  o m
        // Look for the properties file DB.props in the same directory as
        // this program. It will contain default values for the various
        // parameters needed to connect to a database
        Properties p = new Properties();
        try {
            p.load(GetDBInfo.class.getResourceAsStream("DB.props"));
        } catch (Exception e) {
        }

        // Get default values from the properties file
        String driver = p.getProperty("driver"); // Driver class name
        String server = p.getProperty("server", ""); // JDBC URL for server
        String user = p.getProperty("user", ""); // db user name
        String password = p.getProperty("password", ""); // db password

        // These variables don't have defaults
        String database = null; // The db name (appended to server URL)
        String table = null; // The optional name of a table in the db

        // Parse the command-line args to override the default values above
        for (int i = 0; i < args.length; i++) {
            if (args[i].equals("-d"))
                driver = args[++i]; //-d <driver>
            else if (args[i].equals("-s"))
                server = args[++i];//-s <server>
            else if (args[i].equals("-u"))
                user = args[++i]; //-u <user>
            else if (args[i].equals("-p"))
                password = args[++i];
            else if (database == null)
                database = args[i]; // <dbname>
            else if (table == null)
                table = args[i]; // <table>
            else
                throw new IllegalArgumentException("Unknown argument: " + args[i]);
        }

        // Make sure that at least a server or a database were specified.
        // If not, we have no idea what to connect to, and cannot continue.
        if ((server.length() == 0) && (database.length() == 0))
            throw new IllegalArgumentException("No database specified.");

        // Load the db driver, if any was specified.
        if (driver != null)
            Class.forName(driver);

        // Now attempt to open a connection to the specified database on
        // the specified server, using the specified name and password
        c = DriverManager.getConnection(server + database, user, password);

        // Get the DatabaseMetaData object for the connection. This is the
        // object that will return us all the data we're interested in here
        DatabaseMetaData md = c.getMetaData();

        // Display information about the server, the driver, etc.
        System.out.println("DBMS: " + md.getDatabaseProductName() + " " + md.getDatabaseProductVersion());
        System.out.println("JDBC Driver: " + md.getDriverName() + " " + md.getDriverVersion());
        System.out.println("Database: " + md.getURL());
        System.out.println("User: " + md.getUserName());

        // Now, if the user did not specify a table, then display a list of
        // all tables defined in the named database. Note that tables are
        // returned in a ResultSet, just like query results are.
        if (table == null) {
            System.out.println("Tables:");
            ResultSet r = md.getTables("", "", "%", null);
            while (r.next())
                System.out.println("\t" + r.getString(3));
        }

        // Otherwise, list all columns of the specified table.
        // Again, information about the columns is returned in a ResultSet
        else {
            System.out.println("Columns of " + table + ": ");
            ResultSet r = md.getColumns("", "", table, "%");
            while (r.next())
                System.out.println("\t" + r.getString(4) + " : " + r.getString(6));
        }
    }
    // Print an error message if anything goes wrong.
    catch (Exception e) {
        System.err.println(e);
        if (e instanceof SQLException)
            System.err.println(((SQLException) e).getSQLState());
        System.err.println("Usage: java GetDBInfo [-d <driver] " + "[-s <dbserver>]\n"
                + "\t[-u <username>] [-p <password>] <dbname>");
    }
    // Always remember to close the Connection object when we're done!
    finally {
        try {
            c.close();
        } catch (Exception e) {
        }
    }
}

From source file:edu.indiana.d2i.sloan.internal.QueryVMSimulator.java

public static void main(String[] args) {
    QueryVMSimulator simulator = new QueryVMSimulator();

    CommandLineParser parser = new PosixParser();

    try {/*  www.  j a  v a 2 s  . c  o  m*/
        CommandLine line = simulator.parseCommandLine(parser, args);
        String wdir = line.getOptionValue(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.WORKING_DIR));

        if (!HypervisorCmdSimulator.resourceExist(wdir)) {
            logger.error(String.format("Cannot find VM working dir: %s", wdir));
            System.exit(ERROR_CODE.get(ERROR_STATE.VM_NOT_EXIST));
        }

        Properties prop = new Properties();
        String filename = HypervisorCmdSimulator.cleanPath(wdir) + HypervisorCmdSimulator.VM_INFO_FILE_NAME;

        prop.load(new FileInputStream(new File(filename)));

        VMStatus status = new VMStatus(
                VMMode.valueOf(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_MODE))),
                VMState.valueOf(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VM_STATE))), ip,
                Integer.parseInt(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VNC_PORT))),
                Integer.parseInt(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.SSH_PORT))),
                Integer.parseInt(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.VCPU))),
                Integer.parseInt(prop.getProperty(CMD_FLAG_VALUE.get(CMD_FLAG_KEY.MEM))));

        // write state query file so shell script can read the vm state info
        filename = HypervisorCmdSimulator.cleanPath(wdir) + QueryVMSimulator.QUERY_RES_FILE_NAME;
        FileUtils.writeStringToFile(new File(filename), status.toString(), Charset.forName("UTF-8"));

    } catch (ParseException e) {
        logger.error(String.format("Cannot parse input arguments: %s%n, expected:%n%s",
                StringUtils.join(args, " "), simulator.getUsage(100, "", 5, 5, "")));

        System.exit(ERROR_CODE.get(ERROR_STATE.INVALID_INPUT_ARGS));
    } catch (IOException e) {
        logger.error(e.getMessage(), e);
        System.exit(ERROR_CODE.get(ERROR_STATE.IO_ERR));
    }

}

From source file:cu.uci.gws.sdlcrawler.PdfCrawlController.java

public static void main(String[] args) throws Exception {
    Properties cm = PdfCrawlerConfigManager.getInstance().loadConfigFile();
    long startTime = System.currentTimeMillis();
    DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    Date date = new Date();
    System.out.println(dateFormat.format(date));
    int numberOfCrawlers = Integer.parseInt(cm.getProperty("sdlcrawler.NumberOfCrawlers"));
    String pdfFolder = cm.getProperty("sdlcrawler.CrawlPdfFolder");

    CrawlConfig config = new CrawlConfig();

    config.setCrawlStorageFolder(cm.getProperty("sdlcrawler.CrawlStorageFolder"));
    config.setProxyHost(cm.getProperty("sdlcrawler.ProxyHost"));
    if (!"".equals(cm.getProperty("sdlcrawler.ProxyPort"))) {
        config.setProxyPort(Integer.parseInt(cm.getProperty("sdlcrawler.ProxyPort")));
    }//from   ww w .ja v a  2  s.c om
    config.setProxyUsername(cm.getProperty("sdlcrawler.ProxyUser"));
    config.setProxyPassword(cm.getProperty("sdlcrawler.ProxyPass"));
    config.setMaxDownloadSize(Integer.parseInt(cm.getProperty("sdlcrawler.MaxDownloadSize")));
    config.setIncludeBinaryContentInCrawling(
            Boolean.parseBoolean(cm.getProperty("sdlcrawler.IncludeBinaryContent")));
    config.setFollowRedirects(Boolean.parseBoolean(cm.getProperty("sdlcrawler.Redirects")));
    config.setUserAgentString(cm.getProperty("sdlcrawler.UserAgent"));
    config.setMaxDepthOfCrawling(Integer.parseInt(cm.getProperty("sdlcrawler.MaxDepthCrawl")));
    config.setMaxConnectionsPerHost(Integer.parseInt(cm.getProperty("sdlcrawler.MaxConnectionsPerHost")));
    config.setSocketTimeout(Integer.parseInt(cm.getProperty("sdlcrawler.SocketTimeout")));
    config.setMaxOutgoingLinksToFollow(Integer.parseInt(cm.getProperty("sdlcrawler.MaxOutgoingLinks")));
    config.setResumableCrawling(Boolean.parseBoolean(cm.getProperty("sdlcrawler.ResumableCrawling")));
    config.setIncludeHttpsPages(Boolean.parseBoolean(cm.getProperty("sdlcrawler.IncludeHttpsPages")));
    config.setMaxTotalConnections(Integer.parseInt(cm.getProperty("sdlcrawler.MaxTotalConnections")));
    config.setMaxPagesToFetch(Integer.parseInt(cm.getProperty("sdlcrawler.MaxPagesToFetch")));
    config.setPolitenessDelay(Integer.parseInt(cm.getProperty("sdlcrawler.PolitenessDelay")));
    config.setConnectionTimeout(Integer.parseInt(cm.getProperty("sdlcrawler.ConnectionTimeout")));

    System.out.println(config.toString());
    Collection<BasicHeader> defaultHeaders = new HashSet<>();
    defaultHeaders
            .add(new BasicHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"));
    defaultHeaders.add(new BasicHeader("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.3"));
    defaultHeaders.add(new BasicHeader("Accept-Language", "en-US,en,es-ES,es;q=0.8"));
    defaultHeaders.add(new BasicHeader("Connection", "keep-alive"));
    config.setDefaultHeaders(defaultHeaders);

    List<String> list = Files.readAllLines(Paths.get("config/" + cm.getProperty("sdlcrawler.SeedFile")),
            StandardCharsets.UTF_8);
    String[] crawlDomains = list.toArray(new String[list.size()]);

    PageFetcher pageFetcher = new PageFetcher(config);
    RobotstxtConfig robotstxtConfig = new RobotstxtConfig();
    RobotstxtServer robotstxtServer = new RobotstxtServer(robotstxtConfig, pageFetcher);
    CrawlController controller = new CrawlController(config, pageFetcher, robotstxtServer);
    for (String domain : crawlDomains) {
        controller.addSeed(domain);
    }

    PdfCrawler.configure(crawlDomains, pdfFolder);
    controller.start(PdfCrawler.class, numberOfCrawlers);
    DateFormat dateFormat1 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
    Date date1 = new Date();
    System.out.println(dateFormat1.format(date1));
    long endTime = System.currentTimeMillis();
    long totalTime = endTime - startTime;
    System.out.println("Total time:" + totalTime);
}