Example usage for java.lang String chars

List of usage examples for java.lang String chars

Introduction

In this page you can find the example usage for java.lang String chars.

Prototype

@Override
public IntStream chars() 

Source Link

Document

Returns a stream of int zero-extending the char values from this sequence.

Usage

From source file:org.sonar.server.plugins.edition.EditionBundledPluginsTest.java

private String randomizeCase(String s) {
    return s.chars().map(c -> random.nextBoolean() ? Character.toUpperCase(c) : Character.toLowerCase(c))
            .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append).toString();
}

From source file:org.talend.dataprep.dataset.service.DataSetServiceTest.java

@Test
public void should_remove_any_NUL_character() throws Exception {
    // given/*from   w w w .  j a  va2s .c  o  m*/
    final String originalContent = IOUtils
            .toString(this.getClass().getResourceAsStream(DATASET_WITH_NUL_CHAR_CSV));
    assertThat(originalContent.chars().anyMatch((c) -> c == '\u0000'), is(true));
    final String dataSetId = createCSVDataSet(this.getClass().getResourceAsStream(DATASET_WITH_NUL_CHAR_CSV),
            "test");

    // when
    final String content = requestDataSetSample(dataSetId, false, "10");

    // then
    assertThat(content, not(containsString("\\u0000")));
}

From source file:passwords.PwGen.java

public int getEntropy(String i) {
    double c = i.chars().distinct().count();
    double l = i.length();
    int e = (int) Math.round(l * Math.log(c) / Math.log(2));
    return e;/*ww  w  .ja  v  a  2 s.  c  o  m*/
}