Example usage for java.io File separatorChar

List of usage examples for java.io File separatorChar

Introduction

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

Prototype

char separatorChar

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

Click Source Link

Document

The system-dependent default name-separator character.

Usage

From source file:Main.java

public static void main(String[] args) {

    System.out.println(File.separatorChar);

}

From source file:Main.java

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

    File file = new File("dir" + File.separatorChar + "filename.txt");
    file = file.getAbsoluteFile();/*from ww w. j  av  a  2 s.c om*/
}

From source file:Main.java

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

    File file = new File(".." + File.separatorChar + "filename.txt");
    file = file.getAbsoluteFile();//  w w  w.java 2s. com

}

From source file:FileDemo.java

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

    // Display constants
    System.out.println("pathSeparatorChar = " + File.pathSeparatorChar);
    System.out.println("separatorChar = " + File.separatorChar);

}

From source file:FileDemo.java

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

    // Display constants
    System.out.println("pathSeparatorChar = " + File.pathSeparatorChar);
    System.out.println("separatorChar = " + File.separatorChar);

    // Test some methods
    File file = new File(args[0]);
    System.out.println("getName() = " + file.getName());
    System.out.println("getParent() = " + file.getParent());
    System.out.println("getAbsolutePath() = " + file.getAbsolutePath());
    System.out.println("getCanonicalPath() = " + file.getCanonicalPath());
    System.out.println("getPath() = " + file.getPath());
    System.out.println("canRead() = " + file.canRead());
    System.out.println("canWrite() = " + file.canWrite());
}

From source file:Main.java

public static void main(String[] argv) throws Exception {
    String filename = System.getProperty("java.home")
            + "/lib/security/cacerts".replace('/', File.separatorChar);
    FileInputStream is = new FileInputStream(filename);
    KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
    String password = "password";
    keystore.load(is, password.toCharArray());

    PKIXParameters params = new PKIXParameters(keystore);

    params.setRevocationEnabled(false);//from   w w w . j a v  a 2  s.com

    CertPathValidator certPathValidator = CertPathValidator.getInstance(CertPathValidator.getDefaultType());
    CertPath certPath = null;
    CertPathValidatorResult result = certPathValidator.validate(certPath, params);

    PKIXCertPathValidatorResult pkixResult = (PKIXCertPathValidatorResult) result;
    TrustAnchor ta = pkixResult.getTrustAnchor();
    X509Certificate cert = ta.getTrustedCert();
}

From source file:GetURL.java

public static void main(String args[]) throws Exception {
    URL url = new URL("http://www.google.com");
    InputStream urlstream = url.openStream();
    byte[] buffer = new byte[0];
    byte[] chunk = new byte[4096];
    int count;/*  w w w  .  j a v  a  2  s .co  m*/

    while ((count = urlstream.read(chunk)) >= 0) {
        byte[] t = new byte[buffer.length + count];
        System.arraycopy(buffer, 0, t, 0, buffer.length);
        System.arraycopy(chunk, 0, t, buffer.length, count);
        buffer = t;
    }

    String filename = (url.getFile()).replace('/', File.separatorChar);
    File f1 = new File(filename);
    filename = f1.getName();
    FileOutputStream f = null;
    f = new FileOutputStream(filename);
    f.write(buffer);
    f.close();
}

From source file:FileDialogMultipleFileNameSelection.java

public static void main(String[] args) {
    Display display = new Display();
    final Shell shell = new Shell(display);

    FileDialog dlg = new FileDialog(shell, SWT.MULTI);
    Collection files = new ArrayList();
    if (dlg.open() != null) {
        String[] names = dlg.getFileNames();
        for (int i = 0, n = names.length; i < n; i++) {
            StringBuffer buf = new StringBuffer(dlg.getFilterPath());
            if (buf.charAt(buf.length() - 1) != File.separatorChar)
                buf.append(File.separatorChar);
            buf.append(names[i]);//from   w w  w.j a v  a2 s  .co  m
            files.add(buf.toString());
        }
    }
    System.out.println(files);
    display.dispose();

}

From source file:CAList.java

/**
 * <p><!-- Method description --></p>
 *
 *
 * @param args//from  w  w  w . j  a v a  2s  .  com
 */
public static void main(String[] args) {
    try {
        // Load the JDK's cacerts keystore file
        String filename = System.getProperty("java.home")
                + "/lib/security/cacerts".replace('/', File.separatorChar);
        FileInputStream is = new FileInputStream(filename);
        KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
        String password = "changeit";
        keystore.load(is, password.toCharArray());

        // This class retrieves the most-trusted CAs from the keystore
        PKIXParameters params = new PKIXParameters(keystore);

        // Get the set of trust anchors, which contain the most-trusted CA certificates
        Iterator it = params.getTrustAnchors().iterator();
        for (; it.hasNext();) {
            TrustAnchor ta = (TrustAnchor) it.next();

            // Get certificate
            X509Certificate cert = ta.getTrustedCert();
            System.out.println("<issuer>" + cert.getIssuerDN() + "</issuer>\n");
        }
    } catch (CertificateException e) {
    } catch (KeyStoreException e) {
    } catch (NoSuchAlgorithmException e) {
    } catch (InvalidAlgorithmParameterException e) {
    } catch (IOException e) {
    }
}

From source file:MainClass.java

public static void main(String[] arguments) {
    String home, system;/*from ww w .j a  va2 s .  c  o m*/
    home = System.getProperty("user.home", ".");
    system = home + File.separatorChar + ".database";
    System.setProperty("derby.system.home", system);
    createDatabase();
    readDatabase();
}