Exemple #1
0
  public static void main(String[] args) {
    String inputStr = null;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

    try {
      while ((inputStr = reader.readLine()) != null) {
        inputStr = inputStr.trim();

        if (DEST_MATCHER.reset(inputStr).matches()) {
          System.out.println("Destination field!\n");
        } else if (SOURCE_MATCHER.reset(inputStr).matches()) {
          System.out.println("Source field!\n");
        } else if (STRING_MATCHER.reset(inputStr).matches()) {
          System.out.println("String literal!\n");
        } else if (VAR_MATCHER.reset(inputStr).matches()) {
          System.out.println("Variable!\n");
        } else if (NUM_MATCHER.reset(inputStr).matches()) {
          System.out.println("Number!\n");
        } else {
          System.out.println("Huh???\n");
        }
      }
    } catch (Exception ioe) {
      System.out.println("Exception: " + ioe.toString());
      ioe.printStackTrace();
    }
  }
Exemple #2
0
 public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attrs)
     throws IOException {
   if (m != null) m.reset(root.relativize(dir).toString());
   return m == null || m.matches() || m.hitEnd()
       ? FileVisitResult.CONTINUE
       : FileVisitResult.SKIP_SUBTREE;
 }
Exemple #3
0
 public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
   if (attrs.isRegularFile()) {
     if (m != null) m.reset(root.relativize(file).toString());
     if (m == null || m.matches())
       futures.add(exec.submit(new FileLoader(root, file, blocSize)));
   }
   return FileVisitResult.CONTINUE;
 }
Exemple #4
0
 public static void main(String[] args) throws IOException {
   BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
   if (args.length != 1) {
     System.err.println("Usage: MatchLines pattern");
     System.exit(1);
   }
   Pattern patt = Pattern.compile(args[0]);
   Matcher matcher = patt.matcher("");
   String line = null;
   while ((line = is.readLine()) != null) {
     matcher.reset(line);
     if (matcher.find()) {
       System.out.println("MATCH: " + line);
     }
   }
 }