Example usage for com.google.common.base Joiner on

List of usage examples for com.google.common.base Joiner on

Introduction

In this page you can find the example usage for com.google.common.base Joiner on.

Prototype

@CheckReturnValue
public static Joiner on(char separator) 

Source Link

Document

Returns a joiner which automatically places separator between consecutive elements.

Usage

From source file:org.pantsbuild.testproject.deployexcludes.DeployExcludesMain.java

public static void main(String[] args) {
    Set values = ImmutableSortedSet.of("Hello", "World");
    System.out.println("DeployExcludes " + Joiner.on(" ").join(values));
}

From source file:com.pants.testproject.cwdexample.ExampleCwd.java

public static void main(String args[]) {
    if (sourceExists()) {
        System.out.println("Found " + EXAMPLE_SOURCE);
    } else if (resourceExists()) {
        System.out.println("Found " + EXAMPLE_TEXT);
    } else {//from  w w  w .ja  va2  s . com
        // Including Joiner simply to get a 3rdparty jar on the classpath for testing.
        Joiner joiner = Joiner.on(" ");
        System.err.println(joiner.join("Error: Neither", EXAMPLE_SOURCE, "nor", EXAMPLE_TEXT,
                "found. cwd=" + System.getProperty("user.dir")));
        System.exit(1);
    }
}

From source file:com.google.errorprone.refaster.testdata.GenericPlaceholderTemplateExample.java

public static void main(String[] args) {
    List<UUID> list = new ArrayList<>();
    for (int i = 0; i < 10; i++) {
        list.add(UUID.randomUUID());
    }/* w  w w. j av  a  2  s .  c o  m*/
    System.out.println(Joiner.on('\n').join(list));
}

From source file:org.apache.niolex.common.guava.GuavaStrings.java

/**
 * @param args//  w  ww. java2 s  .c  o  m
 */
public static void main(String[] args) {
    String str = CaseFormat.LOWER_HYPHEN.to(CaseFormat.LOWER_CAMEL, "good-morning");
    System.out.println("lower camel => " + str);

    Joiner joiner = Joiner.on("; ").useForNull("null");
    str = joiner.join("nice", "talk", null, "name");
    System.out.println("join on ';' => " + str);
}

From source file:io.brooklyncentral.persistencecleaner.locations.LocationsRemover.java

public static void main(String[] args) {
    String brooklynPersistedStatePath = args.length > 0 ? args[0]
            : Joiner.on(File.separator).join(System.getenv().get("HOME"), "brooklyn",
                    "brooklyn-persisted-state");

    LocationsRemover locationsRemover = new LocationsRemover(brooklynPersistedStatePath);
    locationsRemover.loadAllValidLocations();

    //        locationsRemover.removeInvalidLocations();
}

From source file:fr.assoba.open.perf.GenDist.java

public static void main(String[] args) {
    // Magic number !
    LogNormalDistribution distribution = new LogNormalDistribution(6.73, 2.12);
    ArrayList<Long> list = new ArrayList<Long>();
    for (int i = 0; i < 1023; i++) {
        double d = (1.0 * i) / 1023.0;
        list.add((long) (100 * distribution.inverseCumulativeProbability(d)));
    }//from w  w  w  . j  a  va  2  s  . c o  m
    System.out.print(Joiner.on(",").join(list));

}

From source file:uk.ac.cam.cl.dtg.picky.client.ui.CheckTreeViewPersistenceUtil.java

public static void main(String[] args) {
    List<String> list = new ArrayList<String>();
    list.add("a,2");
    list.add("b");

    System.out.println(list);/*from   ww  w.  ja va  2s .  c om*/
    list = list.stream().map(s -> s.replaceAll(",", "\\\\,")).collect(Collectors.toList());

    String string = Joiner.on(",").join(list);
    System.out.println(string);

    String[] parts = string.split("(?<!\\\\),");
    System.out.println(Arrays.asList(parts));
    List<String> list2 = Arrays.asList(parts).stream().map(s -> s.replaceAll("\\\\,", ","))
            .collect(Collectors.toList());
    System.out.println(list2);
}

From source file:kn.uni.gis.dataimport.FormatStrangeFlickrFormat.java

License:asdf

public static void main(String[] args) throws IOException {
    Iterable<String> readLines = filterNulls(concatLines(Files.readLines(new File(INPUT), Charsets.UTF_8)));
    // BufferedReader reader = Files
    // .newReader(new File(INPUT), Charsets.UTF_8);
    // 1,20,12//w w w  .ja  v  a2s . c  o m
    Files.write(Joiner.on("\n").skipNulls().join(Iterables.transform(readLines, new Function<String, String>() {

        @Override
        public String apply(String input) {
            // System.out.println(input);
            String[] split = input.split(";");

            if (equalss(split[0], "524", "567", "2284", "2720")) {
                return null;
            }

            assertNumbers(split);

            String asdf = Joiner.on("\t").join(split[0], split[19], split[20], "Z", "M", split[3], "");

            System.out.println(asdf);
            return asdf;
        }

        private void assertNumbers(String[] split) {
            if (!!!split[0].equals("Field1")) {
                Preconditions.checkArgument(Double.valueOf(split[19].replace(',', '.')) > 13,
                        split[19] + Arrays.toString(split));
                Preconditions.checkArgument(Double.valueOf(split[20].replace(',', '.')) > 52,
                        split[20] + Arrays.toString(split));
            }
        }
    })).replaceAll(",", "."), new File(OUTPUT), Charsets.UTF_8);
}

From source file:uk.ac.cam.cl.dtg.teaching.programmingtest.java.CurveFitter.java

/** Launch an experimental test of the curve fitter. */
public static void main(String[] args) {
    final double[] y = new double[] { 30, 50, 50, 60, 100, 100, 120, 170, 140, 180, 200, 220, 260, 290, 320,
            280, 320 };//  w w w  . j a  v a 2 s.c  om

    final double[] y2 = new double[] { 1570, 2860, 4340, 5840, 7450, 9020, 10660, 12250, 13900, 15560, 17120,
            18670, 20360, 22220, 23900, 25810, 27350 };

    double[] x = new double[y.length];
    for (int i = 0; i < x.length; ++i) {
        x[i] = scale(i);
    }

    System.out
            .println("x=[" + Joiner.on(",").join(Arrays.stream(x).boxed().collect(Collectors.toList())) + "]");
    System.out
            .println("y=[" + Joiner.on(",").join(Arrays.stream(y).boxed().collect(Collectors.toList())) + "]");
    System.out.println(linearFit(x, y));

    System.out
            .println("x=[" + Joiner.on(",").join(Arrays.stream(x).boxed().collect(Collectors.toList())) + "]");
    System.out
            .println("y=[" + Joiner.on(",").join(Arrays.stream(y2).boxed().collect(Collectors.toList())) + "]");
    System.out.println(linearFit(x, y2));
}

From source file:pl.coffeepower.blog.examples.LambdaExpExample.java

public static void main(String[] args) {
    LambdaExpExample example = new LambdaExpExample();
    Joiner joiner = Joiner.on(", ");
    log.info("numbers: " + joiner.join(example.getNumbers()));
    log.info("odd numbers: " + NumberUtils.getOddNumbers(example.getNumbers()));
    log.info("even numbers: " + NumberUtils.getEvenNumbers(example.getNumbers()));
}