Example usage for java.util Properties Properties

List of usage examples for java.util Properties Properties

Introduction

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

Prototype

public Properties() 

Source Link

Document

Creates an empty property list with no default values.

Usage

From source file:hd3gtv.embddb.MainClass.java

public static void main(String[] args) throws Exception {
    Security.addProvider(new BouncyCastleProvider());

    PoolManager poolmanager = new PoolManager("test");
    poolmanager.startLocalServers();/*w  w w .java 2s  .  c o m*/

    // TODO manage white/black range addr list for autodiscover

    Thread.sleep(50);

    Properties conf = new Properties();
    conf.load(FileUtils.openInputStream(new File("conf.properties")));

    poolmanager.setBootstrapPotentialNodes(
            importConf(poolmanager, conf, poolmanager.getProtocol().getDefaultTCPPort()));
    poolmanager.connectToBootstrapPotentialNodes("Startup");

    Thread.sleep(50);

    poolmanager.startConsole();
}

From source file:com.igalia.metamail.Main.java

public static void main(String[] args) {
    try {//  w w  w.  j  a  va2 s  .c  om
        String filename = "../enron-importer/data/maildir/lay-k/sent/1.";
        byte[] body = FileUtils.readFileToByteArray(new File(filename));
        InputStream input = new ByteArrayInputStream(body);
        Session s = Session.getDefaultInstance(new Properties());

        MailRecord mail = MailRecord.create(s, input);
        System.out.println("To: " + mail.getTo());
    } catch (IOException e) {
        e.printStackTrace();
    } catch (MessagingException e) {
        e.printStackTrace();
    }
}

From source file:mcnutty.music.get.MusicGet.java

public static void main(String[] args) throws Exception {

    //print out music-get
    System.out.println("                     _                      _   ");
    System.out.println(" _ __ ___  _   _ ___(_) ___       __ _  ___| |_ ");
    System.out.println("| '_ ` _ \\| | | / __| |/ __|____ / _` |/ _ \\ __|");
    System.out.println("| | | | | | |_| \\__ \\ | (_|_____| (_| |  __/ |_ ");
    System.out.println("|_| |_| |_|\\__,_|___/_|\\___|     \\__, |\\___|\\__|");
    System.out.println("                                 |___/          \n");

    //these will always be initialised later (but the compiler doesn't know that)
    String directory = "";
    Properties prop = new Properties();

    try (InputStream input = new FileInputStream("config.properties")) {
        prop.load(input);/*from w w w .  j a va2s .c o m*/
        if (prop.getProperty("directory") != null) {
            directory = prop.getProperty("directory");
        } else {
            System.out.println(
                    "Error reading config property 'directory' - using default value of /tmp/musicserver/\n");
            directory = "/tmp/musicserver/";
        }
        if (prop.getProperty("password") == null) {
            System.out.println("Error reading config property 'password' - no default value, exiting\n");
            System.exit(1);
        }
    } catch (IOException e) {
        System.out.println("Error reading config file");
        System.exit(1);
    }

    //create a queue object
    ProcessQueue process_queue = new ProcessQueue();

    try {
        if (args.length > 0 && args[0].equals("clean")) {
            Files.delete(Paths.get("queue.json"));
        }
        //load an existing queue if possible
        String raw_queue = Files.readAllLines(Paths.get("queue.json")).toString();
        JSONArray queue_state = new JSONArray(raw_queue);
        ConcurrentLinkedQueue<QueueItem> loaded_queue = new ConcurrentLinkedQueue<>();
        JSONArray queue = queue_state.getJSONArray(0);
        for (int i = 0; i < queue.length(); i++) {
            JSONObject item = ((JSONObject) queue.get(i));
            QueueItem loaded_item = new QueueItem();
            loaded_item.ip = item.getString("ip");
            loaded_item.real_name = item.getString("name");
            loaded_item.disk_name = item.getString("guid");
            loaded_queue.add(loaded_item);
        }
        process_queue.bucket_queue = loaded_queue;
        System.out.println("Loaded queue from disk\n");
    } catch (Exception ex) {
        //otherwise clean out the music directory and start a new queue
        try {
            Files.walkFileTree(Paths.get(directory), new SimpleFileVisitor<Path>() {
                @Override
                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                    Files.delete(file);
                    return FileVisitResult.CONTINUE;
                }
            });
            Files.delete(Paths.get(directory));
        } catch (Exception e) {
            e.printStackTrace();
        }
        Files.createDirectory(Paths.get(directory));
        System.out.println("Created a new queue\n");
    }

    //start the web server
    StartServer start_server = new StartServer(process_queue, directory);
    new Thread(start_server).start();

    //wit for the web server to spool up
    Thread.sleep(1000);

    //read items from the queue and play them
    while (true) {
        QueueItem next_item = process_queue.next_item();
        if (!next_item.equals(new QueueItem())) {
            //Check the timeout
            int timeout = 547;
            try (FileInputStream input = new FileInputStream("config.properties")) {
                prop.load(input);
                timeout = Integer.parseInt(prop.getProperty("timeout", "547"));
            } catch (Exception e) {
                e.printStackTrace();
            }
            System.out.println("Playing " + next_item.real_name);
            process_queue.set_played(next_item);
            process_queue.save_queue();
            Process p = Runtime.getRuntime().exec("timeout " + timeout
                    + "s mplayer -fs -quiet -af volnorm=2:0.25 " + directory + next_item.disk_name);

            try {
                p.waitFor(timeout, TimeUnit.SECONDS);
                Files.delete(Paths.get(directory + next_item.disk_name));
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else {
            process_queue.bucket_played.clear();
        }
        Thread.sleep(1000);
    }
}

From source file:com.counter.TestServer.java

public static void main(String[] args) throws Exception {
    Server server = new Server(8080);

    Context context = new Context();

    ServletHolder servletHolder = new ServletHolder();

    servletHolder.setInitOrder(1);//  w  w w  .  j  a v a 2  s.c o  m
    servletHolder.setServlet(new CXFServlet());
    servletHolder.setName("CXFServlet");
    servletHolder.setDisplayName("CXF Servlet");
    context.addServlet(servletHolder, "/*");
    context.addEventListener(new ContextLoaderListener());
    Properties initParams = new Properties();
    initParams.put("contextConfigLocation", "classpath:/beans.xml,classpath:/factorybeans.xml");
    context.setInitParams(initParams);
    server.addHandler(context);
    server.start();
}

From source file:com.gnizr.core.delicious.DeliciousImportApp.java

/**
 * @param args//from w w  w  . j a  va  2s  .  c  om
 */
public static void main(String[] args) throws Exception {
    if (args.length != 1) {
        System.out.println("Missing required arguments.");
        System.exit(1);
    }
    Properties prpt = new Properties();
    prpt.load(new FileInputStream(args[0]));
    String dbdrv = prpt.getProperty("gnizr.db.driver");
    String dbUrl = prpt.getProperty("gnizr.db.url");
    String dbUser = prpt.getProperty("gnizr.db.username");
    String dbPass = prpt.getProperty("gnizr.db.password");
    String gnizrUser = prpt.getProperty("gnizr.import.user");
    String gnizrPassword = prpt.getProperty("gnizr.import.password");
    String gnizrEmail = prpt.getProperty("gnizr.import.email");
    String gnizrFullname = prpt.getProperty("gnizr.import.fullname");
    String deliUser = prpt.getProperty("gnizr.import.delicious.user");
    String deliPassword = prpt.getProperty("gnizr.import.delicious.password");

    BasicDataSource datasource = new BasicDataSource();
    datasource.setDriverClassName(dbdrv);
    datasource.setUrl(dbUrl);
    datasource.setUsername(dbUser);
    datasource.setPassword(dbPass);

    GnizrDao gnizrDao = GnizrDao.getInstance(datasource);

    UserManager userManager = new UserManager(gnizrDao);
    BookmarkManager bookmarkManager = new BookmarkManager(gnizrDao);
    FolderManager folderManager = new FolderManager(gnizrDao);

    User gUser = new User();
    gUser.setUsername(gnizrUser);
    gUser.setPassword(gnizrPassword);
    gUser.setFullname(gnizrFullname);
    gUser.setEmail(gnizrEmail);
    gUser.setAccountStatus(AccountStatus.ACTIVE);
    gUser.setCreatedOn(GnizrDaoUtil.getNow());

    DeliciousImport deliciousImport = new DeliciousImport(deliUser, deliPassword, gUser, userManager,
            bookmarkManager, folderManager, true);
    ImportStatus status = deliciousImport.doImport();
    System.out.println("Del.icio.us Import Status: ");
    System.out.println("- total number: " + status.getTotalNumber());
    System.out.println("- number added: " + status.getNumberAdded());
    System.out.println("- number updated: " + status.getNumberUpdated());
    System.out.println("- number failed: " + status.getNumberError());
}

From source file:com.imolinfo.offline.InModelValidation.java

public static void main(String[] args)
        throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {

    SparkConf conf = new SparkConf().setAppName("Train");
    final JavaSparkContext jsc = new JavaSparkContext(conf);
    Properties p = new Properties();
    p.load(new FileInputStream("runtime.properties"));
    GlobalVariable.getInstance().setProperties(p);
    invokePipeline(jsc);//from   w  w w.  ja v a  2s .c om
}

From source file:com.gvmax.web.WebMain.java

@SuppressWarnings("deprecation")
public static void main(String[] args) {
    try {//  w  w  w  .j  a va 2  s.  c  o  m
        MetricRegistry registry = MetricsUtil.getRegistry();
        Properties props = new Properties();
        props.load(new ClassPathResource("/web.properties").getInputStream());

        int httpPort = Integer.parseInt(props.getProperty("web.http.port", "19080"));
        int httpsPort = Integer.parseInt(props.getProperty("web.https.port", "19443"));
        logger.info("Starting server: " + httpPort + " :: " + httpsPort);

        Server server = new Server(httpPort);
        ThreadPool threadPool = new InstrumentedQueuedThreadPool(registry);
        server.setThreadPool(threadPool);

        // Setup HTTPS
        if (new File("gvmax.jks").exists()) {
            SslSocketConnector connector = new SslSocketConnector();
            connector.setPort(httpsPort);
            connector.setKeyPassword(props.getProperty("web.keystore.password"));
            connector.setKeystore("gvmax.jks");
            server.addConnector(connector);
        } else {
            logger.warn("keystore gvmax.jks not found, ssl disabled");
        }

        // Setup WEBAPP
        URL warUrl = WebMain.class.getClassLoader().getResource("webapp");
        String warUrlString = warUrl.toExternalForm();
        WebAppContext ctx = new WebAppContext(warUrlString, "/");
        ctx.setAttribute(MetricsServlet.METRICS_REGISTRY, registry);
        InstrumentedHandler handler = new InstrumentedHandler(registry, ctx);
        server.setHandler(handler);
        server.start();
        server.join();
    } catch (Exception e) {
        logger.error(e);
        System.exit(0);
    }
}

From source file:com.edmunds.etm.client.impl.Daemon.java

public static void main(String[] args) {

    if (args.length == 0) {
        System.out.println("Error provide the name of the service as the first argument");
        return;//from  ww  w. j a v  a  2 s.  c  o  m
    }
    final String serviceName = args[0];

    final Properties properties = new Properties();
    properties.put("serviceName", serviceName);

    final ApplicationContext appCtx = SpringContextLoader.loadClassPathSpringContext(DAEMON_CONTEXT_PATH,
            properties);
    final DaemonConfig daemonConfig = (DaemonConfig) appCtx.getBean("daemonConfig");
    daemonConfig.setServiceName(serviceName);
    final Daemon daemon = (Daemon) appCtx.getBean("daemon");

    if (daemon != null) {
        daemon.run();
    }
}

From source file:com.ibm.watson.developer_cloud.conversation_tone_analyzer_integration.v1.ToneConversationIntegrationV1.java

public static void main(String[] args) throws Exception {

    // load the properties file
    Properties props = new Properties();
    props.load(FileUtils.openInputStream(new File("tone_conversation_integration.properties")));

    // instantiate the conversation service
    ConversationService conversationService = new ConversationService(
            ConversationService.VERSION_DATE_2016_07_11);
    conversationService.setUsernameAndPassword(
            props.getProperty("CONVERSATION_USERNAME", "<conversation_username>"),
            props.getProperty("CONVERSATION_PASSWORD", "<conversation_password>"));

    // instantiate the tone analyzer service
    ToneAnalyzer toneService = new ToneAnalyzer(ToneAnalyzer.VERSION_DATE_2016_05_19);
    toneService.setUsernameAndPassword(props.getProperty("TONE_ANALYZER_USERNAME", "<tone_analyzer_username>"),
            props.getProperty("TONE_ANALYZER_PASSWORD", "<tone_analyzer_password>"));

    // workspace id
    final String workspaceId = props.getProperty("WORKSPACE_ID", "<workspace_id>");

    // maintain history in the context variable - will add a history variable to
    // each of the emotion, social and language tones
    final Boolean maintainHistory = false;

    /**//from   w  w w .j a  v a 2 s .c o  m
     * Input for the conversation service: input (String): an input string (the user's conversation turn) and context
     * (Map<String,Object>: any context that needs to be maintained - either added by the client app or passed in the
     * response from the conversation service on the previous conversation turn.
     */
    final String input = "I am happy";
    final Map<String, Object> context = new HashMap<String, Object>();

    // UPDATE CONTEXT HERE IF CONTINUING AN ONGOING CONVERSATION
    // set local context variable to the context from the last response from the
    // Conversation Service
    // (see the getContext() method of the MessageResponse class in
    // com.ibm.watson.developer_cloud.conversation.v1.model)

    // async call to Tone Analyzer
    toneService.getTone(input, null).enqueue(new ServiceCallback<ToneAnalysis>() {
        @Override
        public void onResponse(ToneAnalysis toneResponsePayload) {

            // update context with the tone data returned by the Tone Analyzer
            ToneDetection.updateUserTone(context, toneResponsePayload, maintainHistory);

            // call Conversation Service with the input and tone-aware context
            MessageRequest newMessage = new MessageRequest.Builder().inputText(input).context(context).build();
            conversationService.message(workspaceId, newMessage)
                    .enqueue(new ServiceCallback<MessageResponse>() {
                        @Override
                        public void onResponse(MessageResponse response) {
                            System.out.println(response);
                        }

                        @Override
                        public void onFailure(Exception e) {
                        }
                    });
        }

        @Override
        public void onFailure(Exception e) {
        }
    });
}

From source file:net.dfs.user.test.Retrieve.java

/**
 * Retrieve application will be started with the main() of the {@link Retrieve}.
 * //from  w  w w. j a v a 2 s  .  c om
 * @param args the parameter which is passed to the main()
 * @throws IOException 
 * @throws FileNotFoundException 
 * @throws IOException
 */

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

    Properties prop = new Properties();
    prop.load(new FileInputStream("server.properties"));

    Retrieve ret = new Retrieve();
    ret.fileNameAnalyzer(prop.getProperty("retrieve.fileName"));

    ApplicationContext context = new ClassPathXmlApplicationContext("net\\dfs\\user\\test\\spring-user.xml");
    RetrievalConnectionHandler retrieve = (RetrievalConnectionHandler) context.getBean("retrieve");

    retrieve.retrieveFile(fileName, extention, InetAddress.getLocalHost().getHostAddress());
    log.debug("The File " + fileName + extention + " Request from the Server");

}