Java Scanner Usage listify(String s, String prefix, String... ignorelist)

Here you can find the source of listify(String s, String prefix, String... ignorelist)

Description

listify

License

Creative Commons License

Declaration

public static  String[] listify(String s, String prefix, String... ignorelist) 

Method Source Code

//package com.java2s;
//License from project: Creative Commons License 

import java.util.ArrayList;

import java.util.Scanner;

public class Main {
    public static /* varargs */ String[] listify(String s, String prefix, String... ignorelist) {
        ArrayList<String> l = new ArrayList<String>();
        Scanner m = new Scanner(s);
        while (m.hasNextLine()) {
            String b = m.nextLine().trim();
            if (b.length() <= 0)
                continue;
            l.add(prefix + b);/* w ww  . ja v a2  s. c  o m*/
        }
        if (ignorelist.length > 0) {
            ArrayList<String> x = new ArrayList<String>();
            for (String a : l) {
                boolean good = true;
                for (String bad : ignorelist) {
                    if (!a.contains((CharSequence) bad))
                        continue;
                    good = false;
                }
                if (!good)
                    continue;
                x.add(a);
            }
            l = x;
        }
        return l.toArray(new String[0]);
    }
}

Related

  1. isYes(String str)
  2. iterate(final String node)
  3. joinSqlStatements(Collection scripts)
  4. leerOpcion(String opciones, String msgUsr, String msgErr)
  5. leerTexto(String msgUsr)
  6. listify(String s, String prefix, String... ignorelist)
  7. loadElements(Scanner scan, int elementCount, int skipCount)
  8. loadStringDoubleMap(Scanner scanner)
  9. menu()