Example usage for java.nio.charset StandardCharsets ISO_8859_1

List of usage examples for java.nio.charset StandardCharsets ISO_8859_1

Introduction

In this page you can find the example usage for java.nio.charset StandardCharsets ISO_8859_1.

Prototype

Charset ISO_8859_1

To view the source code for java.nio.charset StandardCharsets ISO_8859_1.

Click Source Link

Document

ISO Latin Alphabet No.

Usage

From source file:org.sejda.io.BufferedCountingChannelWriter.java

/**
 * Writes the given string in {@link Charsets#ISO_8859_1}
 * // ww  w  . j  a v a  2  s  . c o  m
 * @param value
 * @throws IOException
 */
public void write(String value) throws IOException {
    write(value.getBytes(StandardCharsets.ISO_8859_1));
}

From source file:es.molabs.properties.NodeProperties.java

public void load(InputStream inStream) throws IOException {
    this.load(inStream, StandardCharsets.ISO_8859_1.name());
}

From source file:org.sonar.batch.report.SourcePublisherTest.java

@Test
public void publishEmptySource() throws Exception {
    FileUtils.write(sourceFile, "", StandardCharsets.ISO_8859_1);

    publisher.publish(writer);/*  ww w.java  2 s.co m*/

    File out = writer.getSourceFile(2);
    assertThat(FileUtils.readFileToString(out, StandardCharsets.UTF_8)).isEqualTo("");
}

From source file:org.sonar.scanner.report.SourcePublisherTest.java

@Test
public void publishSourceWithLastEmptyLine() throws Exception {
    FileUtils.write(sourceFile, "1\n2\n3\n4\n", StandardCharsets.ISO_8859_1);

    publisher.publish(writer);// www  .  j  a va2 s  .c om

    File out = writer.getSourceFile(inputFile.batchId());
    assertThat(FileUtils.readFileToString(out, StandardCharsets.UTF_8)).isEqualTo("1\n2\n3\n4\n");
}

From source file:com.softinstigate.restheart.integrationtest.ContentEncodingIT.java

@Test
public void testGzipAcceptEncoding() throws Exception {
    Response resp = notDecompressingExecutor
            .execute(Request.Get(rootUri).addHeader(Headers.ACCEPT_ENCODING_STRING, Headers.GZIP.toString()));

    HttpResponse httpResp = resp.returnResponse();
    assertNotNull(httpResp);//w ww  .j  av  a  2 s . c o m
    HttpEntity entity = httpResp.getEntity();
    assertNotNull(entity);
    StatusLine statusLine = httpResp.getStatusLine();
    assertNotNull(statusLine);

    String content = EntityUtils.toString(entity);

    Header h = httpResp.getFirstHeader("Content-Encoding");

    assertNotNull("check accept encoding header not null", h);
    assertEquals("check accept encoding header value", Headers.GZIP.toString(), h.getValue());

    assertEquals("check status code", HttpStatus.SC_OK, statusLine.getStatusCode());

    try {
        GZIPInputStream gzipis = new GZIPInputStream(
                new ByteArrayInputStream(content.getBytes(StandardCharsets.ISO_8859_1)));

        while (gzipis.read() > 0) {

        }
    } catch (Exception ex) {
        fail("check decompressing content");
    }
}

From source file:com.torchmind.stockpile.server.controller.v1.BlacklistController.java

/**
 * <code>POST /v1/blacklist/</code>
 *
 * Checks any hostname supplied as a form parameter in the post body against the server blacklist.
 *
 * @param hostname a hostname to check against.
 * @return a blacklist result.// w  w  w . ja va  2 s.  com
 */
@Nonnull
@RequestMapping(params = "hostname", method = RequestMethod.POST)
public BlacklistResult check(@Nonnull @RequestParam("hostname") String hostname) {
    // before checking for wildcards check for exact matches of the hostname
    hostname = hostname.toLowerCase();
    String hash = Hashing.sha1().hashString(hostname, StandardCharsets.ISO_8859_1).toString();

    if (this.hashes.contains(hash)) {
        return new BlacklistResult(hostname, true);
    }

    if (IP_ADDRESS_PATTERN.matcher(hostname).matches()) {
        return this.checkAddress(hostname);
    }

    return this.checkHostname(hostname);
}

From source file:org.sonar.batch.report.SourcePublisherTest.java

@Test
public void publishSourceWithLastEmptyLine() throws Exception {
    FileUtils.write(sourceFile, "1\n2\n3\n4\n", StandardCharsets.ISO_8859_1);

    publisher.publish(writer);/*www  .j a  va2 s .c o  m*/

    File out = writer.getSourceFile(2);
    assertThat(FileUtils.readFileToString(out, StandardCharsets.UTF_8)).isEqualTo("1\n2\n3\n4\n");
}

From source file:com.king.platform.net.http.integration.MultiPart.java

@Test
public void postMultiPart() throws Exception {

    AtomicReference<List<FileItem>> partReferences = new AtomicReference<>();
    AtomicReference<Exception> exceptionReference = new AtomicReference<>();

    integrationServer.addServlet(new HttpServlet() {
        @Override/* w  w w  .  j  a v  a 2s . com*/
        protected void doPost(HttpServletRequest req, HttpServletResponse resp)
                throws ServletException, IOException {
            ServletFileUpload servletFileUpload = new ServletFileUpload(new DiskFileItemFactory());

            try {
                List<FileItem> fileItems = servletFileUpload.parseRequest(req);
                partReferences.set(fileItems);
            } catch (FileUploadException e) {
                exceptionReference.set(e);
            }

        }
    }, "/testMultiPart");

    httpClient
            .createPost(
                    "http://localhost:" + port + "/testMultiPart")
            .idleTimeoutMillis(
                    0)
            .totalRequestTimeoutMillis(
                    0)
            .content(
                    new MultiPartBuilder()
                            .addPart(
                                    MultiPartBuilder
                                            .create("text1", "Message 1",
                                                    StandardCharsets.ISO_8859_1)
                                            .contentType("multipart/form-data"))
                            .addPart(MultiPartBuilder.create("binary1", new byte[] { 0x00, 0x01, 0x02 })
                                    .contentType("application/octet-stream").charset(StandardCharsets.UTF_8)
                                    .fileName("application.bin"))
                            .addPart(MultiPartBuilder.create("text2", "Message 2", StandardCharsets.ISO_8859_1))
                            .build())
            .build().execute().join();

    assertNull(exceptionReference.get());

    List<FileItem> fileItems = partReferences.get();
    FileItem fileItem = fileItems.get(1);
    assertEquals("application/octet-stream; charset=UTF-8", fileItem.getContentType());
    assertEquals("binary1", fileItem.getFieldName());
    assertEquals("application.bin", fileItem.getName());

}

From source file:org.sonar.scanner.report.SourcePublisherTest.java

@Test
public void publishTestSource() throws Exception {
    FileUtils.write(sourceFile, "1\n2\n3\n4\n", StandardCharsets.ISO_8859_1);
    // sampleFile.setQualifier(Qualifiers.UNIT_TEST_FILE);

    publisher.publish(writer);/*  w w w . j av  a2 s.  c  om*/

    File out = writer.getSourceFile(inputFile.batchId());
    assertThat(FileUtils.readFileToString(out, StandardCharsets.UTF_8)).isEqualTo("1\n2\n3\n4\n");
}

From source file:org.apache.nifi.security.util.crypto.HashService.java

/**
 * Returns a {@link List} of supported {@link Charset}s on this platform. This is not a complete
 * list, as only the charsets in {@link StandardCharsets} are returned to be consistent across
 * JVM instances.//from w w w  . j  av a2 s  .c o  m
 *
 * @return the list of charsets
 */
public static List<Charset> getSupportedCharsets() {
    return Arrays.asList(StandardCharsets.US_ASCII, StandardCharsets.ISO_8859_1, StandardCharsets.UTF_8,
            StandardCharsets.UTF_16BE, StandardCharsets.UTF_16LE, StandardCharsets.UTF_16);
}