Example usage for java.lang String startsWith

List of usage examples for java.lang String startsWith

Introduction

In this page you can find the example usage for java.lang String startsWith.

Prototype

public boolean startsWith(String prefix) 

Source Link

Document

Tests if this string starts with the specified prefix.

Usage

From source file:europarl.Main.java

public static void main(String[] args) {

    //GLOBAL OPTIONS
    String target_word = new String("plane");
    for (String arg : args) {
        if (arg.startsWith("-")) {
        } else {/*from w w w. j  ava2 s .co  m*/
            target_word = arg;
        }
    }
    if (!Cfg.load_config("config/configuration.properties"))
        return;

    WordAlignment align = new WordAlignment();

    long startTime = System.currentTimeMillis();
    align.setStemmer(new SnowballStemmer("english"));
    align.getFromGz("data/it-en.A3.final.gz", target_word, -1);
    long endTime = System.currentTimeMillis();
    Main.log.info("Read in " + (endTime - startTime) / 1000.0 + " seconds");
    align.print();
    startTime = System.currentTimeMillis();
    endTime = System.currentTimeMillis();
    Main.log.info("Converted n " + (endTime - startTime) / 1000.0 + " seconds");

    align.saveToArff("./data/dataset_" + target_word + ".arff");
    return;
}

From source file:Main.java

public static void main(String[] args) {
    Set<Object> result = new HashSet<Object>();
    Provider[] providers = Security.getProviders();
    for (Provider provider : providers) {
        Set<Object> keys = provider.keySet();
        for (Object key : keys) {
            String data = (String) key;
            data = data.split(" ")[0];
            if (data.startsWith("Alg.Alias")) {
                data = data.substring(10);
            }// ww  w. j  av  a  2  s  .com
            data = data.substring(0, data.indexOf('.'));
            result.add(data);
        }
    }
    for (Object o : result) {
        System.out.println("Service Type = " + o);
    }
}

From source file:io.fabric8.devops.projects.finder.gogs.Main.java

public static void main(String[] args) {
    if (args.length > 0) {
        String arg0 = args[0];
        if (arg0.startsWith("-h") || arg0.startsWith("--h") || arg0.startsWith("?")) {
            System.out.println("Queries gogs for the available repositories");
            System.out.println("");
            System.out.println("Configure via the following environment variables:");
            System.out.println("");
            System.out/*from w  ww  .  j a  v a  2s.c o  m*/
                    .println("  GOGS_SERVICE_HOST:     the host name or IP address of the gogs HTTP REST API");
            System.out
                    .println("  GOGS_SERVICE_PORT:     the port of the gogs HTTP REST API (omit for port 80)");
            System.out.println("  JENKINS_GOGS_USER:     user name to login to gogs");
            System.out.println("  JENKINS_GOGS_PASSWORD: password to login to gogs");
            System.out.println("");
            return;
        }
    }
    Main main = new Main();
    main.run();
}

From source file:Main.java

  public static void main(String[] argv) throws Exception {
  Set result = new HashSet();
  Provider[] providers = Security.getProviders();
  for (int i = 0; i < providers.length; i++) {
    Set keys = providers[i].keySet();
    for (Iterator it = keys.iterator(); it.hasNext();) {
      String key = (String) it.next();
      key = key.split(" ")[0];

      if (key.startsWith("Alg.Alias.")) {
        // Strip the alias
        key = key.substring(10);// w w w  .j  av a  2s  .c  om
      }
      int ix = key.indexOf('.');
      result.add(key.substring(0, ix));
    }
  }
  System.out.println(result);
}

From source file:org.corfudb.sharedlog.examples.ConfigClnt.java

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

    DefaultHttpClient httpclient = new DefaultHttpClient();
    final BufferedReader prompt = new BufferedReader(new InputStreamReader(System.in));

    CorfuConfiguration C = null;/*from  w w w  .  java  2 s  .co  m*/

    while (true) {

        System.out.print("> ");
        String line = prompt.readLine();
        if (line.startsWith("get")) {

            HttpGet httpget = new HttpGet("http://localhost:8000/corfu");

            System.out.println("Executing request: " + httpget.getRequestLine());
            HttpResponse response = (HttpResponse) httpclient.execute(httpget);

            System.out.println("----------------------------------------");
            System.out.println(response.getStatusLine());
            // response.getEntity().writeTo(System.out);
            // System.out.println();
            // System.out.println("----------------------------------------");

            C = new CorfuConfiguration(response.getEntity().getContent());
        } else {

            if (C == null) {
                System.out.println("configuration not set yet!");
                continue;
            }

            HttpPost httppost = new HttpPost("http://localhost:8000/corfu");
            httppost.setEntity(new StringEntity(C.ConfToXMLString()));

            System.out.println("Executing request: " + httppost.getRequestLine());
            HttpResponse response = httpclient.execute(httppost);

            System.out.println("----------------------------------------");
            System.out.println(response.getStatusLine());
            response.getEntity().writeTo(System.out);

        }
    }
    // httpclient.close();
}

From source file:MainClass.java

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

    URL u = new URL("http://www.java2s.com/binary.dat");
    URLConnection uc = u.openConnection();
    String contentType = uc.getContentType();
    int contentLength = uc.getContentLength();
    if (contentType.startsWith("text/") || contentLength == -1) {
        throw new IOException("This is not a binary file.");
    }/* w  w w .ja v a 2  s . c om*/
    InputStream raw = uc.getInputStream();
    InputStream in = new BufferedInputStream(raw);
    byte[] data = new byte[contentLength];
    int bytesRead = 0;
    int offset = 0;
    while (offset < contentLength) {
        bytesRead = in.read(data, offset, data.length - offset);
        if (bytesRead == -1)
            break;
        offset += bytesRead;
    }
    in.close();

    if (offset != contentLength) {
        throw new IOException("Only read " + offset + " bytes; Expected " + contentLength + " bytes");
    }

    String filename = u.getFile().substring(filename.lastIndexOf('/') + 1);
    FileOutputStream out = new FileOutputStream(filename);
    out.write(data);
    out.flush();
    out.close();
}

From source file:Deet.java

public static void main(String... args) {
    if (args.length != 4) {
        err.format("Usage: java Deet <classname> <langauge> <country> <variant>%n");
        return;//from w  w  w. j  a  v a  2 s.  co m
    }

    try {
        Class<?> c = Class.forName(args[0]);
        Object t = c.newInstance();

        Method[] allMethods = c.getDeclaredMethods();
        for (Method m : allMethods) {
            String mname = m.getName();
            if (!mname.startsWith("test") || (m.getGenericReturnType() != boolean.class)) {
                continue;
            }
            Type[] pType = m.getGenericParameterTypes();
            if ((pType.length != 1) || Locale.class.isAssignableFrom(pType[0].getClass())) {
                continue;
            }

            out.format("invoking %s()%n", mname);
            try {
                m.setAccessible(true);
                Object o = m.invoke(t, new Locale(args[1], args[2], args[3]));
                out.format("%s() returned %b%n", mname, (Boolean) o);

                // Handle any exceptions thrown by method to be invoked.
            } catch (InvocationTargetException x) {
                Throwable cause = x.getCause();
                err.format("invocation of %s failed: %s%n", mname, cause.getMessage());
            }
        }

        // production code should handle these exceptions more gracefully
    } catch (ClassNotFoundException x) {
        x.printStackTrace();
    } catch (InstantiationException x) {
        x.printStackTrace();
    } catch (IllegalAccessException x) {
        x.printStackTrace();
    }
}

From source file:Main.java

public static void main(String[] args) {

    String str = "www.java2s.com";
    System.out.println(str);/*from  w  ww  .  j  av  a 2  s  .  com*/

    String startstr1 = "www";
    String startstr2 = "http://";

    boolean retval1 = str.startsWith(startstr1);
    boolean retval2 = str.startsWith(startstr2);

    System.out.println(retval1);
    System.out.println(retval2);
}

From source file:GCS_Auth.java

public static void main(String[] args) {
    String client_id = null;//from   w  ww  . j  a va  2 s .  c o  m
    String key = null;

    for (String a : args) {
        if (a.startsWith("--key="))
            key = a.split("=")[1];
        if (a.startsWith("--client_id="))
            client_id = a.split("=")[1];
    }

    if ((args.length < 2) || client_id == null || key == null) {
        System.out.println("specify --key= --client_id=");
        System.exit(-1);
    }

    GCS_Auth j = new GCS_Auth(client_id, key);
}

From source file:mjc.ARMMain.java

public static void main(String[] args) {

    for (String arg : args) {
        if (!arg.startsWith("-")) { // ignore flags
            try {
                File in = new File(arg);
                File out = new File(FilenameUtils.removeExtension(in.getName()) + ".s");
                compile(new FileInputStream(in), new PrintStream(out));
            } catch (FileNotFoundException e) {
                System.err.println("Error: " + e.getMessage());
                System.exit(1);//  w  w w .  j  a v a 2 s  .  c o m
            } catch (Throwable t) {
                System.err.println("Could not compile: " + t.getMessage());
                System.exit(1);
            }
        }
    }

    // All went well, exit with status 0.
    System.exit(0);

}