Example usage for java.io File separator

List of usage examples for java.io File separator

Introduction

In this page you can find the example usage for java.io File separator.

Prototype

String separator

To view the source code for java.io File separator.

Click Source Link

Document

The system-dependent default name-separator character, represented as a string for convenience.

Usage

From source file:MondrianService.java

public static void main(String[] arg) {
    System.out.println("Starting Mondrian Connector for Infoveave");
    Properties prop = new Properties();
    InputStream input = null;/*w  w w .  ja  v  a 2 s.  c o m*/
    int listenPort = 9998;
    int threads = 100;
    try {
        System.out.println("Staring from :" + getSettingsPath());
        input = new FileInputStream(getSettingsPath() + File.separator + "MondrianService.properties");
        prop.load(input);
        listenPort = Integer.parseInt(prop.getProperty("port"));
        threads = Integer.parseInt(prop.getProperty("maxThreads"));
        if (input != null) {
            input.close();
        }
        System.out.println("Found MondrianService.Properties");
    } catch (FileNotFoundException e) {
    } catch (IOException e) {
    }

    port(listenPort);
    threadPool(threads);
    enableCORS("*", "*", "*");

    ObjectMapper mapper = new ObjectMapper();
    MondrianConnector connector = new MondrianConnector();
    get("/ping", (request, response) -> {
        response.type("application/json");
        return "\"Here\"";
    });

    post("/cubes", (request, response) -> {
        response.type("application/json");
        try {
            Query queryObject = mapper.readValue(request.body(), Query.class);
            response.status(200);
            return mapper.writeValueAsString(connector.GetCubes(queryObject));
        } catch (JsonParseException ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        } catch (Exception ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        }
    });

    post("/measures", (request, response) -> {
        response.type("application/json");
        try {
            Query queryObject = mapper.readValue(request.body(), Query.class);
            response.status(200);
            return mapper.writeValueAsString(connector.GetMeasures(queryObject));
        } catch (JsonParseException ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        } catch (Exception ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        }
    });

    post("/dimensions", (request, response) -> {
        response.type("application/json");
        try {
            Query queryObject = mapper.readValue(request.body(), Query.class);
            response.status(200);
            return mapper.writeValueAsString(connector.GetDimensions(queryObject));
        } catch (JsonParseException ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        } catch (Exception ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        }
    });

    post("/cleanCache", (request, response) -> {
        response.type("application/json");
        try {
            Query queryObject = mapper.readValue(request.body(), Query.class);
            response.status(200);
            return mapper.writeValueAsString(connector.CleanCubeCache(queryObject));
        } catch (JsonParseException ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        } catch (Exception ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        }
    });

    post("/executeQuery", (request, response) -> {
        response.type("application/json");
        try {
            Query queryObject = mapper.readValue(request.body(), Query.class);
            response.status(200);
            String content = mapper.writeValueAsString(connector.ExecuteQuery2(queryObject));
            return content;
        } catch (JsonParseException ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        } catch (Exception ex) {
            response.status(400);
            return mapper.writeValueAsString(new Error(ex.getMessage()));
        }
    });
}

From source file:com.vimukti.accounter.developer.api.PublicKeyGenerator.java

/**
 * @param args/*from ww w.  j  a  v a  2  s .  c o m*/
 * @throws NoSuchProviderException
 * @throws NoSuchAlgorithmException
 * @throws InvalidKeySpecException
 * @throws IOException
 * @throws CertificateException
 * @throws KeyStoreException
 * @throws UnrecoverableEntryException
 * @throws URISyntaxException
 */
public static void main(String[] args) throws KeyStoreException, NoSuchAlgorithmException, CertificateException,
        IOException, UnrecoverableEntryException {
    FileInputStream is = new FileInputStream(
            ServerConfiguration.getConfig() + File.separator + "license.keystore");
    KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
    String password = "liceseStorePassword";
    keystore.load(is, password.toCharArray());
    PrivateKeyEntry entry = (PrivateKeyEntry) keystore.getEntry("licenseAlias",
            new PasswordProtection(ServerConfiguration.getLicenseKeystorePWD().toCharArray()));
    Key key = entry.getPrivateKey();
    System.out.println((PrivateKey) key);
    PublicKey publicKey = entry.getCertificate().getPublicKey();
    System.out.println(publicKey);

    byte[] encoded = publicKey.getEncoded();
    byte[] encodeBase64 = Base64.encodeBase64(encoded);
    System.out.println("Public Key:" + new String(encodeBase64));

}

From source file:com.msopentech.odatajclient.engine.performance.PerfTestReporter.java

public static void main(final String[] args) throws Exception {
    // 1. check input directory
    final File reportdir = new File(args[0] + File.separator + "target" + File.separator + "surefire-reports");
    if (!reportdir.isDirectory()) {
        throw new IllegalArgumentException("Expected directory, got " + args[0]);
    }//w ww  .  j  ava 2s.c  o  m

    // 2. read test data from surefire output
    final File[] xmlReports = reportdir.listFiles(new FilenameFilter() {

        @Override
        public boolean accept(final File dir, final String name) {
            return name.endsWith("-output.txt");
        }
    });

    final Map<String, Map<String, Double>> testData = new TreeMap<String, Map<String, Double>>();

    for (File xmlReport : xmlReports) {
        final BufferedReader reportReader = new BufferedReader(new FileReader(xmlReport));
        try {
            while (reportReader.ready()) {
                String line = reportReader.readLine();
                final String[] parts = line.substring(0, line.indexOf(':')).split("\\.");

                final String testClass = parts[0];
                if (!testData.containsKey(testClass)) {
                    testData.put(testClass, new TreeMap<String, Double>());
                }

                line = reportReader.readLine();

                testData.get(testClass).put(parts[1],
                        Double.valueOf(line.substring(line.indexOf(':') + 2, line.indexOf('['))));
            }
        } finally {
            IOUtils.closeQuietly(reportReader);
        }
    }

    // 3. build XSLX output (from template)
    final HSSFWorkbook workbook = new HSSFWorkbook(new FileInputStream(args[0] + File.separator + "src"
            + File.separator + "test" + File.separator + "resources" + File.separator + XLS));

    for (Map.Entry<String, Map<String, Double>> entry : testData.entrySet()) {
        final Sheet sheet = workbook.getSheet(entry.getKey());

        int rows = 0;

        for (Map.Entry<String, Double> subentry : entry.getValue().entrySet()) {
            final Row row = sheet.createRow(rows++);

            Cell cell = row.createCell(0);
            cell.setCellValue(subentry.getKey());

            cell = row.createCell(1);
            cell.setCellValue(subentry.getValue());
        }
    }

    final FileOutputStream out = new FileOutputStream(
            args[0] + File.separator + "target" + File.separator + XLS);
    try {
        workbook.write(out);
    } finally {
        IOUtils.closeQuietly(out);
    }
}

From source file:gda.util.PackageMaker.java

/**
 * @param args//from   w w  w . j ava 2 s.co m
 */
public static void main(String args[]) {
    String destDir = null;
    if (args.length == 0)
        return;
    String filename = args[0];
    if (args.length > 1)
        destDir = args[1];
    try {
        ClassParser cp = new ClassParser(filename);
        JavaClass classfile = cp.parse();
        String packageName = classfile.getPackageName();
        String apackageName = packageName.replace(".", File.separator);
        if (destDir != null)
            destDir = destDir + File.separator + apackageName;
        else
            destDir = apackageName;
        File destFile = new File(destDir);
        File existFile = new File(filename);
        File parentDir = new File(existFile.getAbsolutePath().substring(0,
                existFile.getAbsolutePath().lastIndexOf(File.separator)));
        String allFiles[] = parentDir.list();
        Vector<String> selectedFiles = new Vector<String>();
        String toMatch = existFile.getName().substring(0, existFile.getName().lastIndexOf("."));
        for (int i = 0; i < allFiles.length; i++) {
            if (allFiles[i].startsWith(toMatch + "$"))
                selectedFiles.add(allFiles[i]);
        }
        FileUtils.copyFileToDirectory(existFile, destFile);
        Object[] filestoCopy = selectedFiles.toArray();
        for (int i = 0; i < filestoCopy.length; i++) {
            FileUtils.copyFileToDirectory(new File((String) filestoCopy[i]), destFile);
        }
    }

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

From source file:cognition.pipeline.Main.java

/**
 * Entry point of Cognition-DNC/* ww w  .  j a  va  2s  . co  m*/
 */
public static void main(String[] args) {
    if (requiresHelp(args)) {
        CommandHelper.printHelp();
        System.exit(0);
    }

    String path = "file:" + getCurrentFolder() + File.separator + "config" + File.separator
            + "applicationContext.xml";
    logger.info("Loading context from " + path);

    context = new ClassPathXmlApplicationContext(path);

    Options options = getOptions();
    CommandLineParser parser = new GnuParser();

    Runtime.getRuntime().addShutdownHook(getShutDownBehaviour());
    try {
        CommandLine cmd = parser.parse(options, args);
        processCommands(cmd);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:org.soasecurity.wso2.mutual.auth.oauth2.client.MutualSSLOAuthClient.java

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

    File file = new File((new File(".")).getCanonicalPath() + File.separator + "src" + File.separator + "main"
            + File.separator + "resources" + File.separator + "keystore" + File.separator + keyStoreName);

    if (!file.exists()) {
        throw new Exception("Key Store file can not be found in " + file.getCanonicalPath());
    }//from   w  w  w . ja v  a2s. c  o m

    //Set trust store, you need to import server's certificate of CA certificate chain in to this
    //key store
    System.setProperty("javax.net.ssl.trustStore", file.getCanonicalPath());
    System.setProperty("javax.net.ssl.trustStorePassword", keyStorePassword);

    //Set key store, this must contain the user private key
    //here we have use both trust store and key store as the same key store
    //But you can use a separate key store for key store an trust store.
    System.setProperty("javax.net.ssl.keyStore", file.getCanonicalPath());
    System.setProperty("javax.net.ssl.keyStorePassword", keyStorePassword);

    HttpClient client = new HttpClient();

    HttpMethod method = new PostMethod(endPoint);

    // Base64 encoded client id & secret
    method.setRequestHeader("Authorization",
            "Basic T09pN2dpUjUwdDZtUmU1ZkpmWUhVelhVa1QwYTpOOUI2dDZxQ0E2RFp2eTJPQkFIWDhjVlI1eUlh");
    method.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    NameValuePair pair1 = new NameValuePair();
    pair1.setName("grant_type");
    pair1.setValue("x509");

    NameValuePair pair2 = new NameValuePair();
    pair2.setName("username");
    pair2.setValue("asela");

    NameValuePair pair3 = new NameValuePair();
    pair3.setName("password");
    pair3.setValue("asela");

    method.setQueryString(new NameValuePair[] { pair1, pair2, pair3 });

    int statusCode = client.executeMethod(method);

    if (statusCode != HttpStatus.SC_OK) {

        System.out.println("Failed: " + method.getStatusLine());

    } else {

        byte[] responseBody = method.getResponseBody();

        System.out.println(new String(responseBody));
    }
}

From source file:enrichment.Disambiguate.java

/**prerequisites:
 * cd silk_2.5.3/*_links//from  www  .ja  v  a  2  s . c o m
 * cat *.nt|sort  -t' ' -k3   > $filename
 * 
 * @param args $filename
 * @throws IOException
 * @throws URISyntaxException
 */
public static void main(String[] args) {
    File file = new File(args[0]);
    if (file.isDirectory()) {
        args = file.list(new OnlyExtFilenameFilter("nt"));
    }

    BufferedReader in;
    for (int q = 0; q < args.length; q++) {
        String filename = null;
        if (file.isDirectory()) {
            filename = file.getPath() + File.separator + args[q];
        } else {
            filename = args[q];
        }
        try {
            FileWriter output = new FileWriter(filename + "_disambiguated.nt");
            String prefix = "@prefix rdrel: <http://rdvocab.info/RDARelationshipsWEMI/> .\n"
                    + "@prefix dbpedia:    <http://de.dbpedia.org/resource/> .\n"
                    + "@prefix frbr:   <http://purl.org/vocab/frbr/core#> .\n"
                    + "@prefix lobid: <http://lobid.org/resource/> .\n"
                    + "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n"
                    + "@prefix foaf: <http://xmlns.com/foaf/0.1/> .\n"
                    + "@prefix mo: <http://purl.org/ontology/mo/> .\n"
                    + "@prefix wikipedia: <https://de.wikipedia.org/wiki/> .";
            output.append(prefix + "\n\n");
            in = new BufferedReader(new InputStreamReader(new FileInputStream(filename)));

            HashMap<String, HashMap<String, ArrayList<String>>> hm = new HashMap<String, HashMap<String, ArrayList<String>>>();
            String s;
            HashMap<String, ArrayList<String>> hmLobid = new HashMap<String, ArrayList<String>>();
            Stack<String> old_object = new Stack<String>();

            while ((s = in.readLine()) != null) {
                String[] triples = s.split(" ");
                String object = triples[2].substring(1, triples[2].length() - 1);
                if (old_object.size() > 0 && !old_object.firstElement().equals(object)) {
                    hmLobid = new HashMap<String, ArrayList<String>>();
                    old_object = new Stack<String>();
                }
                old_object.push(object);
                String subject = triples[0].substring(1, triples[0].length() - 1);
                System.out.print("\nSubject=" + object);
                System.out.print("\ntriples[2]=" + triples[2]);
                hmLobid.put(subject, getAllCreators(new URI(subject)));
                hm.put(object, hmLobid);

            }
            // get all dbpedia resources
            for (String key_one : hm.keySet()) {
                System.out.print("\n==============\n==== " + key_one + "\n===============");
                int resources_cnt = hm.get(key_one).keySet().size();
                ArrayList<String>[] creators = new ArrayList[resources_cnt];
                HashMap<String, Integer> creators_backed = new HashMap<String, Integer>();
                int x = 0;
                // get all lobid_resources subsumed under the dbpedia resource
                for (String subject_uri : hm.get(key_one).keySet()) {
                    creators[x] = new ArrayList<String>();
                    System.out.print("\n     subject_uri=" + subject_uri);
                    Iterator<String> ite = hm.get(key_one).get(subject_uri).iterator();
                    int y = 0;
                    // get all creators of the lobid resource
                    while (ite.hasNext()) {
                        String creator = ite.next();
                        System.out.print("\n          " + creator);
                        if (creators_backed.containsKey(creator)) {
                            y = creators_backed.get(creator);
                        } else {
                            y = creators_backed.size();
                            creators_backed.put(creator, y);
                        }
                        while (creators[x].size() <= y) {
                            creators[x].add("-");
                        }
                        creators[x].set(y, creator);
                        y++;
                    }
                    x++;
                }
                if (creators_backed.size() == 1) {
                    System.out
                            .println("\n" + "Every resource pointing to " + key_one + " has the same creator!");
                    for (String key_two : hm.get(key_one).keySet()) {
                        output.append("<" + key_two + "> rdrel:workManifested <" + key_one + "> .\n");
                        output.append("<" + key_two + ">  mo:wikipedia <"
                                + key_one.replaceAll("dbpedia\\.org/resource", "wikipedia\\.org/wiki")
                                + "> .\n");
                    }
                } /*else  {
                    for (int a = 0; a < creators.length; a++) {
                       System.out.print(creators[a].toString()+",");
                    }
                  }*/
            }

            output.flush();
            if (output != null) {
                output.close();
            }
        } catch (Exception e) {
            System.out.print("Exception while working on " + filename + ": \n");
            e.printStackTrace(System.out);
        }
    }
}

From source file:jfix.db4o.engine.migration.Db4oToPerst.java

public static void main(String[] args) throws IOException {
    if (args.length == 0) {
        System.out.println("Database name required.");
        return;//  w ww .  j ava  2 s . c  om
    }

    String databaseName = args[0];

    PersistenceEngine db4oEngine = new PersistenceEngineDb4o();
    db4oEngine.open(databaseName);

    ObjectDatabase db4o = new ObjectDatabase(db4oEngine);
    db4o.open();

    PersistenceEngine perstEngine = new PersistenceEnginePerst();
    perstEngine.open(databaseName);

    ObjectDatabase perst = new ObjectDatabase(perstEngine);
    perst.open();

    for (Persistent p : db4o.query(Persistent.class)) {
        perst.save(p);
    }

    FileUtils.copyDirectory(new File(db4o.getBlobDirectory() + File.separator + "blob"),
            new File(perst.getBlobDirectory() + File.separator + "blob"));

    perst.close();
    db4o.close();
}

From source file:jfix.db4o.engine.migration.PerstToDb4o.java

public static void main(String[] args) throws IOException {
    if (args.length == 0) {
        System.out.println("Database name required.");
        return;/*from   w  w w .ja v a2  s .  c om*/
    }

    String databaseName = args[0];

    PersistenceEngine perstEngine = new PersistenceEnginePerst();
    perstEngine.open(databaseName);

    ObjectDatabase perst = new ObjectDatabase(perstEngine);
    perst.open();

    PersistenceEngine db4oEngine = new PersistenceEngineDb4o();
    db4oEngine.open(databaseName);

    ObjectDatabase db4o = new ObjectDatabase(db4oEngine);
    db4o.open();

    for (Persistent p : perst.query(Persistent.class)) {
        db4o.save(p);
    }

    FileUtils.copyDirectory(new File(perst.getBlobDirectory() + File.separator + "blob"),
            new File(db4o.getBlobDirectory() + File.separator + "blob"));

    db4o.close();
    perst.close();
}

From source file:com.wso2.rfid.Main.java

public static void main(String[] args) throws IOException {
    Properties configs = new Properties();
    configs.load(/* w ww .  j  a v a 2s  .c o m*/
            new FileInputStream(System.getProperty("rpi.agent.home") + File.separator + "config.properties"));

    Server server = new Server(InetSocketAddress.createUnresolved("127.0.0.1", 8084));
    ServletHandler handler = new ServletHandler();
    server.setHandler(handler);
    handler.addServletWithMapping(RFIDReaderServlet.class, "/rfid");
    String controlCenterURL = configs.getProperty("control.center.url");
    System.out.println("Using RPi Control Center: " + controlCenterURL);
    String tokenEndpoint = configs.getProperty("token.endpoint");
    System.out.println("Using token endpoint: " + tokenEndpoint);
    APICall.setTokenEndpoint(tokenEndpoint);
    String primaryNwInterface = configs.getProperty("primary.nw.interface");
    String userRegEndpoint = configs.getProperty("user.registration.endpoint");
    System.out.println("Using user registration endpoint: " + userRegEndpoint);
    APICall.setUserRegistrationEndpoint(userRegEndpoint);
    scheduler.scheduleWithFixedDelay(new MonitoringTask(controlCenterURL, primaryNwInterface), 0, 10,
            TimeUnit.SECONDS);

    try {
        server.start();
        server.join();
    } catch (Exception e) {
        e.printStackTrace();
    }
}