Ejemplo n.º 1
0
  public void first() {
    // System.out.println("Inside First. This is called only once");
    java.util.Scanner s = null;

    try {
      s = new java.util.Scanner(new java.io.BufferedReader(new java.io.FileReader("sample")));
      s.useLocale(java.util.Locale.US);
      position = 0;
      while (s.hasNext()) {
        if (s.hasNextLine()) {
          String c = s.nextLine();
          ch[position] = c.charAt(0);
          for (int i = 0; i < 35; i++) {
            Character cha = new Character(c.charAt(i + 1));
            String st = cha.toString();
            data[position][i] = Integer.parseInt(st);
          }
          position++;
        }
      }
    } catch (java.io.IOException ert) {
      javax.swing.JOptionPane.showMessageDialog(
          null, ert, "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
    }

    try {
      s = new java.util.Scanner(new java.io.BufferedReader(new java.io.FileReader("imageload")));
      s.useLocale(java.util.Locale.US);
      while (s.hasNext()) {
        if (s.hasNextLine()) {
          imagedir = s.nextLine();
        }
      }
    } catch (java.io.IOException ert) {
      javax.swing.JOptionPane.showMessageDialog(
          null, ert, "Error", javax.swing.JOptionPane.ERROR_MESSAGE);
    }
    s.close();
    if (imagedir.equals("")) {
      javax.swing.JOptionPane.showMessageDialog(
          null,
          "This must be your first run of Live! Character Recognition.\nPlease set an image folder.",
          "Problem loading image",
          javax.swing.JOptionPane.INFORMATION_MESSAGE);
    } else {
      im.running();
    }
  }
Ejemplo n.º 2
0
 static String convertStreamToString(java.io.InputStream is) {
   java.util.Scanner s = new java.util.Scanner(is).useDelimiter("\\A");
   return s.hasNext() ? s.next() : "";
 }