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:com.joseflavio.unhadegato.Concentrador.java

/**
 * @param args [0] = Diretrio de configuraes.
 */// w  w w .j av  a 2  s .  c o  m
public static void main(String[] args) {

    log.info(Util.getMensagem("unhadegato.iniciando"));

    try {

        /***********************/

        if (args.length > 0) {
            if (!args[0].isEmpty()) {
                configuracao = new File(args[0]);
                if (!configuracao.isDirectory()) {
                    String msg = Util.getMensagem("unhadegato.diretorio.incorreto");
                    System.out.println(msg);
                    log.error(msg);
                    System.exit(1);
                }
            }
        }

        if (configuracao == null) {
            configuracao = new File(System.getProperty("user.home") + File.separator + "unhadegato");
            configuracao.mkdirs();
        }

        log.info(Util.getMensagem("unhadegato.diretorio.endereco", configuracao.getAbsolutePath()));

        /***********************/

        File confGeralArq = new File(configuracao, "unhadegato.conf");

        if (!confGeralArq.exists()) {
            try (InputStream is = Concentrador.class.getResourceAsStream("/unhadegato.conf");
                    OutputStream os = new FileOutputStream(confGeralArq);) {
                IOUtils.copy(is, os);
            }
        }

        Properties confGeral = new Properties();

        try (FileInputStream fis = new FileInputStream(confGeralArq)) {
            confGeral.load(fis);
        }

        String prop_porta = confGeral.getProperty("porta");
        String prop_porta_segura = confGeral.getProperty("porta.segura");
        String prop_seg_pri = confGeral.getProperty("seguranca.privada");
        String prop_seg_pri_senha = confGeral.getProperty("seguranca.privada.senha");
        String prop_seg_pri_tipo = confGeral.getProperty("seguranca.privada.tipo");
        String prop_seg_pub = confGeral.getProperty("seguranca.publica");
        String prop_seg_pub_senha = confGeral.getProperty("seguranca.publica.senha");
        String prop_seg_pub_tipo = confGeral.getProperty("seguranca.publica.tipo");

        if (StringUtil.tamanho(prop_porta) == 0)
            prop_porta = "8885";
        if (StringUtil.tamanho(prop_porta_segura) == 0)
            prop_porta_segura = "8886";
        if (StringUtil.tamanho(prop_seg_pri) == 0)
            prop_seg_pri = "servidor.jks";
        if (StringUtil.tamanho(prop_seg_pri_senha) == 0)
            prop_seg_pri_senha = "123456";
        if (StringUtil.tamanho(prop_seg_pri_tipo) == 0)
            prop_seg_pri_tipo = "JKS";
        if (StringUtil.tamanho(prop_seg_pub) == 0)
            prop_seg_pub = "cliente.jks";
        if (StringUtil.tamanho(prop_seg_pub_senha) == 0)
            prop_seg_pub_senha = "123456";
        if (StringUtil.tamanho(prop_seg_pub_tipo) == 0)
            prop_seg_pub_tipo = "JKS";

        /***********************/

        File seg_pri = new File(prop_seg_pri);
        if (!seg_pri.isAbsolute())
            seg_pri = new File(configuracao.getAbsolutePath() + File.separator + prop_seg_pri);

        if (seg_pri.exists()) {
            System.setProperty("javax.net.ssl.keyStore", seg_pri.getAbsolutePath());
            System.setProperty("javax.net.ssl.keyStorePassword", prop_seg_pri_senha);
            System.setProperty("javax.net.ssl.keyStoreType", prop_seg_pri_tipo);
        }

        File seg_pub = new File(prop_seg_pub);
        if (!seg_pub.isAbsolute())
            seg_pub = new File(configuracao.getAbsolutePath() + File.separator + prop_seg_pub);

        if (seg_pub.exists()) {
            System.setProperty("javax.net.ssl.trustStore", seg_pub.getAbsolutePath());
            System.setProperty("javax.net.ssl.trustStorePassword", prop_seg_pub_senha);
            System.setProperty("javax.net.ssl.trustStoreType", prop_seg_pub_tipo);
        }

        /***********************/

        new Thread() {

            File arquivo = new File(configuracao, "copaibas.conf");

            long ultimaData = -1;

            @Override
            public void run() {

                while (true) {

                    long data = arquivo.lastModified();

                    if (data > ultimaData) {
                        executarCopaibas(arquivo);
                        ultimaData = data;
                    }

                    try {
                        Thread.sleep(5 * 1000);
                    } catch (InterruptedException e) {
                        return;
                    }

                }

            }

        }.start();

        /***********************/

        log.info(Util.getMensagem("unhadegato.conexao.esperando"));

        log.info(Util.getMensagem("copaiba.porta.normal.abrindo", prop_porta));
        Portal portal1 = new Portal(new SocketServidor(Integer.parseInt(prop_porta), false, true));

        log.info(Util.getMensagem("copaiba.porta.segura.abrindo", prop_porta_segura));
        Portal portal2 = new Portal(new SocketServidor(Integer.parseInt(prop_porta_segura), true, true));

        portal1.start();
        portal2.start();

        portal1.join();

        /***********************/

    } catch (Exception e) {

        log.error(e.getMessage(), e);

    } finally {

        for (CopaibaGerenciador gerenciador : gerenciadores.values())
            gerenciador.encerrar();
        gerenciadores.clear();
        gerenciadores = null;

    }

}

From source file:net.itransformers.idiscover.discoverylisteners.XmlTopologyDeviceLogger.java

public static void main(String[] args) throws IOException, JAXBException {
    String path = "devices_and_models\\lab\\undirected";
    File dir = new File(path);
    String[] files = dir.list(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return (name.endsWith(".hml"));
        }/*from  w ww.  j a v a 2s  .c o m*/
    });
    Map<String, String> params = new HashMap<String, String>();
    params.put("path", path);
    params.put("conf/xslt", "iDiscover\\conf\\xslt\\transformator3.xslt");
    XmlTopologyDeviceLogger logger = new XmlTopologyDeviceLogger(params, null, null);

    for (String fileName : files) {
        FileInputStream is = new FileInputStream(path + File.separator + fileName);
        DiscoveredDeviceData discoveredDeviceData;
        try {
            discoveredDeviceData = JaxbMarshalar.unmarshal(DiscoveredDeviceData.class, is);
        } finally {
            is.close();
        }
        String deviceName = fileName.substring("device-".length(), fileName.length() - ".xml".length());
        logger.handleDevice(deviceName, null, discoveredDeviceData, null);
    }

}

From source file:org.biopax.validator.BiopaxValidatorClient.java

/**
 * Checks BioPAX files using the online BioPAX Validator. 
 * // www  .  j  a  v a2  s  . com
 * @see <a href="http://www.biopax.org/validator">BioPAX Validator Webservice</a>
 * 
 * @param argv
 * @throws IOException
 */
public static void main(String[] argv) throws IOException {
    if (argv.length == 0) {
        System.err.println("Available parameters: \n"
                + "<path> <output> [xml|html|biopax] [auto-fix] [only-errors] [maxerrors=n] [notstrict]\n"
                + "\t- validate a BioPAX file/directory (up to ~25MB in total size, -\n"
                + "\totherwise, please use the biopax-validator.jar instead)\n"
                + "\tin the directory using the online BioPAX Validator service\n"
                + "\t(generates html or xml report, or gets the processed biopax\n"
                + "\t(cannot fix all errros though) see http://www.biopax.org/validator)");
        System.exit(-1);
    }

    final String input = argv[0];
    final String output = argv[1];

    File fileOrDir = new File(input);
    if (!fileOrDir.canRead()) {
        System.err.println("Cannot read from " + input);
        System.exit(-1);
    }
    if (output == null || output.isEmpty()) {
        System.err.println("No output file specified (for the validation report).");
        System.exit(-1);
    }

    // default options
    RetFormat outf = RetFormat.HTML;
    boolean fix = false;
    Integer maxErrs = null;
    Behavior level = null; //will report both errors and warnings
    String profile = null;

    // match optional arguments
    for (int i = 2; i < argv.length; i++) {
        if ("html".equalsIgnoreCase(argv[i])) {
            outf = RetFormat.HTML;
        } else if ("xml".equalsIgnoreCase(argv[i])) {
            outf = RetFormat.XML;
        } else if ("biopax".equalsIgnoreCase(argv[i])) {
            outf = RetFormat.OWL;
        } else if ("auto-fix".equalsIgnoreCase(argv[i])) {
            fix = true;
        } else if ("only-errors".equalsIgnoreCase(argv[i])) {
            level = Behavior.ERROR;
        } else if ((argv[i]).toLowerCase().startsWith("maxerrors=")) {
            String num = argv[i].substring(10);
            maxErrs = Integer.valueOf(num);
        } else if ("notstrict".equalsIgnoreCase(argv[i])) {
            profile = "notstrict";
        }
    }

    // collect files
    Collection<File> files = new HashSet<File>();

    if (fileOrDir.isDirectory()) {
        // validate all the OWL files in the folder
        FilenameFilter filter = new FilenameFilter() {
            public boolean accept(File dir, String name) {
                return (name.endsWith(".owl"));
            }
        };

        for (String s : fileOrDir.list(filter)) {
            files.add(new File(fileOrDir.getCanonicalPath() + File.separator + s));
        }
    } else {
        files.add(fileOrDir);
    }

    // upload and validate using the default URL: http://www.biopax.org/biopax-validator/check.html        
    if (!files.isEmpty()) {
        BiopaxValidatorClient val = new BiopaxValidatorClient();
        val.validate(fix, profile, outf, level, maxErrs, null, files.toArray(new File[] {}),
                new FileOutputStream(output));
    }
}

From source file:Main.java

public static String getDirPath(String base, String dir) {
    return base + dir + File.separator;
}

From source file:Main.java

public static String appendSlash(String definitions) {
    return definitions.endsWith(File.separator) ? definitions : definitions + File.separator;
}

From source file:Main.java

public static String makePath(String path1, String path2) {
    if (path1.endsWith(File.separator))
        return path1 + path2;

    return path1 + File.separator + path2;
}

From source file:Main.java

public static String getFileName(String url) {
    return url.substring(url.lastIndexOf(File.separator) + 1, url.lastIndexOf("."));
}

From source file:Main.java

public static String makePath(String path, String name) {
    String str1 = File.separator;
    String p = "";
    if (path.endsWith(str1)) {
        p = path + name;/*  w  w  w  .  ja  va  2s.c om*/
    } else {
        p = path + str1 + name;
    }
    return p;
}

From source file:Main.java

private static String getPath(File mediaStorageDir) {
    return mediaStorageDir.getPath() + File.separator;
}

From source file:Main.java

public static String clearDirectory(String str) {
    int i = str.lastIndexOf(File.separator);
    if (i != -1) {
        return clearSuffix(str.substring(i + 1, str.length()));
    }/*from   w ww  . j a  v a 2s . c o  m*/
    return str;
}