Example usage for java.util Arrays toString

List of usage examples for java.util Arrays toString

Introduction

In this page you can find the example usage for java.util Arrays toString.

Prototype

public static String toString(Object[] a) 

Source Link

Document

Returns a string representation of the contents of the specified array.

Usage

From source file:csv.parser.CSVParser.java

@SuppressWarnings("resource")
public static void main(String[] args) throws Exception {
    String file_to_parse;// w  w  w  .  jav  a2 s  .  c o  m
    String[] val_array;
    file_to_parse = "./input/E-library-data-3.csv";
    //Build reader instance
    //Read CSV file
    CSVReader reader = new CSVReader(new FileReader(file_to_parse), ';', '"', 1);

    //Read all rows at once
    List<String[]> allRows = reader.readAll();

    //        Read CSV line by line and use the string array as you want
    for (String[] row : allRows) {
        for (int i = 0; i < row.length; i++) {
            //Removing all newlines, tabs and '&' characters(invalid XML character)
            row[i] = row[i].replaceAll("(\\r|\\n|\\r\\n)+", " ");
            row[i] = row[i].replaceAll(System.getProperty("line.separator"), "; ");
            row[i] = row[i].replaceAll("&", "and");
        }

        System.out.println(Arrays.toString(row));
    }
    //Get the input fields
    List<String[]> map = getMap();
    String[] field;
    //Numbering for folders, folderNum is incremented for each new file
    long folderNum;
    folderNum = 0;
    for (String[] row : allRows) {
        //Creating new folder
        File file1 = new File("./output//newdir//folder" + folderNum + "");
        file1.mkdirs();
        //Creating content file
        PrintWriter writer_content = new PrintWriter("./output//newdir//folder" + folderNum + "//contents",
                "UTF-16");
        //Creating metadata_lrmi.xml
        PrintWriter writer_lrmi = new PrintWriter(
                "./output//newdir//folder" + folderNum + "//metadata_lrmi.xml", "UTF-16");
        //Creating content.xml
        PrintWriter writer = new PrintWriter("./output//newdir//folder" + folderNum + "//content.xml",
                "UTF-16");
        writer.println("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"no\"?>");
        writer.println("<dublin_core schema=\"dc\">");
        writer_lrmi.println("<?xml version=\"1.0\" encoding=\"utf-16\" standalone=\"no\"?>");
        writer_lrmi.println("<dublin_core shema=\"lrmi\">");
        for (int i = 0; i < row.length; i++) {
            //After snooping data, we have to change these setting for each new csv file, as the data fileds are many times mismatched
            //These if-else statements take care of mismatched steps.
            if (i == 43) {
                continue;
            } else if (i == 43) {
                field = map.get(42);
            } else if (i == 44) {
                field = map.get(43);
            } else if (i == 45 || i == 46) {
                continue;
            } else {
                field = map.get(i);
            }
            //Separate multiple values
            val_array = parseVal(row[i]);
            //                if (val_array.length == 0) {
            //                    continue;
            //                }
            PrintWriter useWriter = writer;
            if (field[0].equals("lrmi")) {
                useWriter = writer_lrmi;
            }
            switch (field.length) {
            case 2:
                writeXML(useWriter, field[1], "", val_array);
                break;
            case 3:
                writeXML(useWriter, field[1], field[2], val_array);
                break;
            default:

            }
        }
        folderNum++;
        writer.println("</dublin_core>");
        writer_lrmi.println("</dublin_core>");
        writer.close();
        writer_lrmi.close();
        writer_content.close();
    }
}

From source file:com.garyclayburg.BootVaadin.java

public static void main(String[] args) {
    log.info("running main with args: " + Arrays.toString(args));
    ensureActiveProfile();//from   w w  w.  j  a  v  a 2  s  .c  om
    ApplicationContext ctx = SpringApplication.run(BootUp.class, args);
    log.info("active profiles: " + Arrays.toString(ctx.getEnvironment().getActiveProfiles()));

    log.info("Beans loaded by spring / spring boot");
    String[] beanNames = ctx.getBeanDefinitionNames();
    Arrays.sort(beanNames);
    for (String beanName : beanNames) {
        log.info(beanName);
    }
    log.info("");
    log.info("BootVaadin Server is ready for e-business");

}

From source file:com.appunity.ant.util.NewClass.java

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

    Collection<File> listFiles = FileUtils.listFiles(srcDir, new String[] { "java" }, true);
    int size = 0;
    System.out.println("listFiles = " + listFiles.size());
    for (final File file : listFiles) {
        CharsetDetector charsetDetector = new CharsetDetector();
        String[] detectAllCharset = charsetDetector.detectCharset(file);
        if (detectAllCharset != null && detectAllCharset.length == 1 && "GB2312".equals(detectAllCharset[0])) {
            System.out.println(Arrays.toString(detectAllCharset) + file.getAbsolutePath());
        } else {/*from  w  ww. j a v a2s  . co m*/
            System.out.println(Arrays.toString(detectAllCharset) + file.getAbsolutePath());
        }
    }
}

From source file:edu.umd.cloud9.example.bigram.AnalyzeBigramCount.java

@SuppressWarnings({ "static-access" })
public static void main(String[] args) {
    Options options = new Options();

    options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT));

    CommandLine cmdline = null;//from  w w w .  j  a v  a2 s.co m
    CommandLineParser parser = new GnuParser();

    try {
        cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
        System.err.println("Error parsing command line: " + exp.getMessage());
        System.exit(-1);
    }

    if (!cmdline.hasOption(INPUT)) {
        System.out.println("args: " + Arrays.toString(args));
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(120);
        formatter.printHelp(AnalyzeBigramCount.class.getName(), options);
        ToolRunner.printGenericCommandUsage(System.out);
        System.exit(-1);
    }

    String inputPath = cmdline.getOptionValue(INPUT);
    System.out.println("input path: " + inputPath);
    List<PairOfWritables<Text, IntWritable>> bigrams = SequenceFileUtils.readDirectory(new Path(inputPath));

    Collections.sort(bigrams, new Comparator<PairOfWritables<Text, IntWritable>>() {
        public int compare(PairOfWritables<Text, IntWritable> e1, PairOfWritables<Text, IntWritable> e2) {
            if (e2.getRightElement().compareTo(e1.getRightElement()) == 0) {
                return e1.getLeftElement().compareTo(e2.getLeftElement());
            }

            return e2.getRightElement().compareTo(e1.getRightElement());
        }
    });

    int singletons = 0;
    int sum = 0;
    for (PairOfWritables<Text, IntWritable> bigram : bigrams) {
        sum += bigram.getRightElement().get();

        if (bigram.getRightElement().get() == 1) {
            singletons++;
        }
    }

    System.out.println("total number of unique bigrams: " + bigrams.size());
    System.out.println("total number of bigrams: " + sum);
    System.out.println("number of bigrams that appear only once: " + singletons);

    System.out.println("\nten most frequent bigrams: ");

    Iterator<PairOfWritables<Text, IntWritable>> iter = Iterators.limit(bigrams.iterator(), 10);
    while (iter.hasNext()) {
        PairOfWritables<Text, IntWritable> bigram = iter.next();
        System.out.println(bigram.getLeftElement() + "\t" + bigram.getRightElement());
    }
}

From source file:de.upb.timok.run.DataGenerator.java

/**
 * @param args//  ww w  .  j a v a  2s. c o  m
 * @throws IOException
 * @throws InterruptedException
 */
public static void main(String[] args) throws IOException, InterruptedException {
    final DataGenerator sp = new DataGenerator();
    new JCommander(sp, args);
    sp.dataString = args[0];
    logger.info("Running DataGenerator with args" + Arrays.toString(args));
    MasterSeed.setSeed(1234);
    sp.run();
}

From source file:edu.umd.cloud9.example.bigram.AnalyzeBigramRelativeFrequencyJson.java

@SuppressWarnings({ "static-access" })
public static void main(String[] args) {
    Options options = new Options();

    options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT));

    CommandLine cmdline = null;/*from   w  w w.  jav  a 2  s  . c  o  m*/
    CommandLineParser parser = new GnuParser();

    try {
        cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
        System.err.println("Error parsing command line: " + exp.getMessage());
        System.exit(-1);
    }

    if (!cmdline.hasOption(INPUT)) {
        System.out.println("args: " + Arrays.toString(args));
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(120);
        formatter.printHelp(AnalyzeBigramRelativeFrequencyJson.class.getName(), options);
        ToolRunner.printGenericCommandUsage(System.out);
        System.exit(-1);
    }

    String inputPath = cmdline.getOptionValue(INPUT);
    System.out.println("input path: " + inputPath);

    List<PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable>> pairs = SequenceFileUtils
            .readDirectory(new Path(inputPath));

    List<PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable>> list1 = Lists.newArrayList();
    List<PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable>> list2 = Lists.newArrayList();

    for (PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable> p : pairs) {
        BigramRelativeFrequencyJson.MyTuple bigram = p.getLeftElement();

        if (bigram.getJsonObject().get("Left").getAsString().equals("light")) {
            list1.add(p);
        }

        if (bigram.getJsonObject().get("Left").getAsString().equals("contain")) {
            list2.add(p);
        }
    }

    Collections.sort(list1,
            new Comparator<PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable>>() {
                public int compare(PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable> e1,
                        PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable> e2) {
                    if (e1.getRightElement().compareTo(e2.getRightElement()) == 0) {
                        return e1.getLeftElement().compareTo(e2.getLeftElement());
                    }

                    return e2.getRightElement().compareTo(e1.getRightElement());
                }
            });

    Iterator<PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable>> iter1 = Iterators
            .limit(list1.iterator(), 10);
    while (iter1.hasNext()) {
        PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable> p = iter1.next();
        BigramRelativeFrequencyJson.MyTuple bigram = p.getLeftElement();
        System.out.println(bigram + "\t" + p.getRightElement());
    }

    Collections.sort(list2,
            new Comparator<PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable>>() {
                public int compare(PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable> e1,
                        PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable> e2) {
                    if (e1.getRightElement().compareTo(e2.getRightElement()) == 0) {
                        return e1.getLeftElement().compareTo(e2.getLeftElement());
                    }

                    return e2.getRightElement().compareTo(e1.getRightElement());
                }
            });

    Iterator<PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable>> iter2 = Iterators
            .limit(list2.iterator(), 10);
    while (iter2.hasNext()) {
        PairOfWritables<BigramRelativeFrequencyJson.MyTuple, FloatWritable> p = iter2.next();
        BigramRelativeFrequencyJson.MyTuple bigram = p.getLeftElement();
        System.out.println(bigram + "\t" + p.getRightElement());
    }
}

From source file:TopicPublisher.java

public static void main(String[] argv) throws Exception {
    TopicPublisher p = new TopicPublisher();
    String[] unknown = CommandLineSupport.setOptions(p, argv);
    if (unknown.length > 0) {
        System.out.println("Unknown options: " + Arrays.toString(unknown));
        System.exit(-1);//  w  w w.j av a  2 s .  com
    }
    p.run();
}

From source file:edu.umd.cloud9.example.bigram.AnalyzeBigramRelativeFrequency.java

@SuppressWarnings({ "static-access" })
public static void main(String[] args) {
    Options options = new Options();

    options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT));

    CommandLine cmdline = null;/*w w  w.  j  av  a  2s . com*/
    CommandLineParser parser = new GnuParser();

    try {
        cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
        System.err.println("Error parsing command line: " + exp.getMessage());
        System.exit(-1);
    }

    if (!cmdline.hasOption(INPUT)) {
        System.out.println("args: " + Arrays.toString(args));
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(120);
        formatter.printHelp(AnalyzeBigramRelativeFrequency.class.getName(), options);
        ToolRunner.printGenericCommandUsage(System.out);
        System.exit(-1);
    }

    String inputPath = cmdline.getOptionValue(INPUT);
    System.out.println("input path: " + inputPath);

    List<PairOfWritables<PairOfStrings, FloatWritable>> pairs = SequenceFileUtils
            .readDirectory(new Path(inputPath));

    List<PairOfWritables<PairOfStrings, FloatWritable>> list1 = Lists.newArrayList();
    List<PairOfWritables<PairOfStrings, FloatWritable>> list2 = Lists.newArrayList();

    for (PairOfWritables<PairOfStrings, FloatWritable> p : pairs) {
        PairOfStrings bigram = p.getLeftElement();

        if (bigram.getLeftElement().equals("light")) {
            list1.add(p);
        }
        if (bigram.getLeftElement().equals("contain")) {
            list2.add(p);
        }
    }

    Collections.sort(list1, new Comparator<PairOfWritables<PairOfStrings, FloatWritable>>() {
        public int compare(PairOfWritables<PairOfStrings, FloatWritable> e1,
                PairOfWritables<PairOfStrings, FloatWritable> e2) {
            if (e1.getRightElement().compareTo(e2.getRightElement()) == 0) {
                return e1.getLeftElement().compareTo(e2.getLeftElement());
            }

            return e2.getRightElement().compareTo(e1.getRightElement());
        }
    });

    Iterator<PairOfWritables<PairOfStrings, FloatWritable>> iter1 = Iterators.limit(list1.iterator(), 10);
    while (iter1.hasNext()) {
        PairOfWritables<PairOfStrings, FloatWritable> p = iter1.next();
        PairOfStrings bigram = p.getLeftElement();
        System.out.println(bigram + "\t" + p.getRightElement());
    }

    Collections.sort(list2, new Comparator<PairOfWritables<PairOfStrings, FloatWritable>>() {
        public int compare(PairOfWritables<PairOfStrings, FloatWritable> e1,
                PairOfWritables<PairOfStrings, FloatWritable> e2) {
            if (e1.getRightElement().compareTo(e2.getRightElement()) == 0) {
                return e1.getLeftElement().compareTo(e2.getLeftElement());
            }

            return e2.getRightElement().compareTo(e1.getRightElement());
        }
    });

    Iterator<PairOfWritables<PairOfStrings, FloatWritable>> iter2 = Iterators.limit(list2.iterator(), 10);
    while (iter2.hasNext()) {
        PairOfWritables<PairOfStrings, FloatWritable> p = iter2.next();
        PairOfStrings bigram = p.getLeftElement();
        System.out.println(bigram + "\t" + p.getRightElement());
    }
}

From source file:edu.umd.cloud9.example.bigram.AnalyzeBigramRelativeFrequencyTuple.java

@SuppressWarnings({ "static-access" })
public static void main(String[] args) throws Exception {
    Options options = new Options();

    options.addOption(OptionBuilder.withArgName("path").hasArg().withDescription("input path").create(INPUT));

    CommandLine cmdline = null;/*from  w ww.j a v  a 2s . c  om*/
    CommandLineParser parser = new GnuParser();

    try {
        cmdline = parser.parse(options, args);
    } catch (ParseException exp) {
        System.err.println("Error parsing command line: " + exp.getMessage());
        System.exit(-1);
    }

    if (!cmdline.hasOption(INPUT)) {
        System.out.println("args: " + Arrays.toString(args));
        HelpFormatter formatter = new HelpFormatter();
        formatter.setWidth(120);
        formatter.printHelp(AnalyzeBigramRelativeFrequencyJson.class.getName(), options);
        ToolRunner.printGenericCommandUsage(System.out);
        System.exit(-1);
    }

    String inputPath = cmdline.getOptionValue(INPUT);
    System.out.println("input path: " + inputPath);

    List<PairOfWritables<Tuple, FloatWritable>> pairs = SequenceFileUtils.readDirectory(new Path(inputPath));

    List<PairOfWritables<Tuple, FloatWritable>> list1 = Lists.newArrayList();
    List<PairOfWritables<Tuple, FloatWritable>> list2 = Lists.newArrayList();

    for (PairOfWritables<Tuple, FloatWritable> p : pairs) {
        Tuple bigram = p.getLeftElement();

        if (bigram.get(0).equals("light")) {
            list1.add(p);
        }

        if (bigram.get(0).equals("contain")) {
            list2.add(p);
        }
    }

    Collections.sort(list1, new Comparator<PairOfWritables<Tuple, FloatWritable>>() {
        @SuppressWarnings("unchecked")
        public int compare(PairOfWritables<Tuple, FloatWritable> e1, PairOfWritables<Tuple, FloatWritable> e2) {
            if (e1.getRightElement().compareTo(e2.getRightElement()) == 0) {
                return e1.getLeftElement().compareTo(e2.getLeftElement());
            }

            return e2.getRightElement().compareTo(e1.getRightElement());
        }
    });

    Iterator<PairOfWritables<Tuple, FloatWritable>> iter1 = Iterators.limit(list1.iterator(), 10);
    while (iter1.hasNext()) {
        PairOfWritables<Tuple, FloatWritable> p = iter1.next();
        Tuple bigram = p.getLeftElement();
        System.out.println(bigram + "\t" + p.getRightElement());
    }

    Collections.sort(list2, new Comparator<PairOfWritables<Tuple, FloatWritable>>() {
        @SuppressWarnings("unchecked")
        public int compare(PairOfWritables<Tuple, FloatWritable> e1, PairOfWritables<Tuple, FloatWritable> e2) {
            if (e1.getRightElement().compareTo(e2.getRightElement()) == 0) {
                return e1.getLeftElement().compareTo(e2.getLeftElement());
            }

            return e2.getRightElement().compareTo(e1.getRightElement());
        }
    });

    Iterator<PairOfWritables<Tuple, FloatWritable>> iter2 = Iterators.limit(list2.iterator(), 10);
    while (iter2.hasNext()) {
        PairOfWritables<Tuple, FloatWritable> p = iter2.next();
        Tuple bigram = p.getLeftElement();
        System.out.println(bigram + "\t" + p.getRightElement());
    }
}

From source file:net.oneandone.shared.artifactory.App.java

public static void main(String[] args) throws ParseException, IOException, NotFoundException {
    initLogging();//from   w  w  w  .  j  av a2 s .  c  o m
    LOG.info("CLI: {}", Arrays.toString(args));
    final Options options = new Options()
            .addOption("l", "uri", true, "Base-URI in the form of " + DEFAULT_ARTIFACTORY_URI)
            .addOption("u", "user", true, "Username").addOption("p", "password", true, "Password")
            .addOption("d", "debug", false, "Turn on debugging");
    final CommandLine commandline = new BasicParser().parse(options, args);
    if (commandline.hasOption("d")) {
        LOG.info("Setting debug");
        java.util.logging.Logger.getLogger("net.oneandone.shared.artifactory").setLevel(Level.ALL);
    }
    final List<String> argList = commandline.getArgList();
    LOG.info("ARGS: {}", argList);
    Injector injector = Guice.createInjector(new ArtifactoryModule());
    App instance = injector.getInstance(App.class);
    instance.preemptiveRequestInterceptor.addCredentialsForHost("web.de", "foo", "bar");
    List<ArtifactoryStorage> search = instance.searchByGav.search("repo1-cache", Gav.valueOf(argList.get(0)));
    LOG.info("Got {} search results", search.size());
}