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:Main.java

public static void main(String[] args) throws Exception {
    System.out.println(StandardCharsets.ISO_8859_1.name());
}

From source file:Main.java

public static void main(String[] args) throws Exception {
    Connection con = DriverManager.getConnection("jdbc:h2:mem:");
    Statement s = con.createStatement();
    s.execute("CREATE TABLE Table1 (Column1 CLOB)");

    InputStream is = new FileInputStream("data.txt");
    Reader rdr = new InputStreamReader(is, StandardCharsets.ISO_8859_1);
    PreparedStatement ps = con.prepareStatement("INSERT INTO Table1 (Column1) VALUES (?)");
    ps.setCharacterStream(1, rdr);//ww  w . j av a2s. c om
    ps.executeUpdate();

    ResultSet rs = s.executeQuery("SELECT Column1 FROM Table1");
    int rowNumber = 0;
    while (rs.next()) {
        String str = rs.getString("Column1");
        System.out.println(String.format("Row %d: CLOB is %d character(s) long.", ++rowNumber, str.length()));
    }
    rs.close();
    con.close();
}

From source file:in.bookmylab.Utils.java

public static String hashPassword(String password) {
    String hashed = null;//  w w w  . jav a  2s  . co m
    try {
        if (!StringUtils.isBlank(password)) {
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            byte[] hash = digest.digest((salt + password).getBytes(StandardCharsets.ISO_8859_1));
            //hashed = Base64.getEncoder().encodeToString(hash);
            hashed = Base64.encodeBase64String(hash);
        }
    } catch (NoSuchAlgorithmException ex) {
        log.log(Level.SEVERE, "Could not hash string.", ex);
    }
    return hashed;
}

From source file:gov.va.oia.terminology.converters.sharedUtils.umlsUtils.AbbreviationExpansion.java

public static HashMap<String, AbbreviationExpansion> load(InputStream is) throws IOException {
    HashMap<String, AbbreviationExpansion> results = new HashMap<>();

    BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.ISO_8859_1));
    String line = br.readLine();/*from  www . j  a v a  2 s .  co m*/
    while (line != null) {
        if (StringUtils.isBlank(line) || line.startsWith("#")) {
            line = br.readLine();
            continue;
        }
        String[] cols = line.split("\t");

        AbbreviationExpansion ae = new AbbreviationExpansion(cols[0], cols[1],
                (cols.length > 2 ? cols[2] : null));

        results.put(ae.getAbbreviation(), ae);
        line = br.readLine();
    }
    return results;
}

From source file:org.openstreetmap.gui.persistence.JSONPersistence.java

/**
 * Loads the marker data from file.//from ww w.j a va2 s  .co m
 * 
 * @param pFineName
 *            The name of the source file.
 * @return An array of MarkerData loaded from file.
 * @throws PersistenceException
 *             If there's any problem with the load.
 */
public static MarkerData[] loadMarkers(String pFineName) {
    try {
        List<String> lines = Files.readAllLines(Paths.get(pFineName), StandardCharsets.ISO_8859_1);
        StringBuffer buffer = new StringBuffer();
        for (String string : lines) {
            buffer.append(string.trim());
        }

        List<MarkerData> markers = new Vector<>();
        JSONObject geometryCollection = new JSONObject(buffer.toString());
        if (geometryCollection.has("geometries")) {
            JSONArray points = geometryCollection.getJSONArray("geometries");
            for (int i = 0; i < points.length(); i++) {
                markers.add(extractMarker(points.getJSONObject(i)));
            }
        }

        if (geometryCollection.has("features")) {
            JSONArray features = geometryCollection.getJSONArray("features");
            for (int i = 0; i < features.length(); i++) {
                // currently disabled
                markers.add(extractFeature(features.getJSONObject(i)));
            }
        }

        return markers.toArray(new MarkerData[0]);
    } catch (IOException exception) {
        throw new PersistenceException(exception);
    }
}

From source file:org.openhab.binding.froeling.internal.net.TelnetSession.java

public void open(String host, int port) throws IOException {
    if (this.telnetClient != null) {
        this.telnetClient.connect(host, port);
        this.telnetClient.setKeepAlive(true);

        this.nbreader = new NonblockingBufferedReader(new BufferedReader(
                new InputStreamReader(this.telnetClient.getInputStream(), StandardCharsets.ISO_8859_1), 1024));
    }//w  w w  . ja v a2s  .  c o m
}

From source file:org.zalando.logbook.httpclient.ResponseTest.java

@Test
public void shouldReturnContentTypesCharsetIfGiven() {
    delegate.addHeader("Content-Type", "text/plain;charset=ISO-8859-1");

    assertThat(unit.getCharset(), is(StandardCharsets.ISO_8859_1));
}

From source file:org.wuspba.ctams.ui.server.ServerUtils.java

public static String convertEntity(HttpEntity entity) throws IOException {
    String str;/*from   w  w  w.j a v a2s  .c  o  m*/
    StringBuilder buff = new StringBuilder();
    try (BufferedReader in = new BufferedReader(
            new InputStreamReader(entity.getContent(), StandardCharsets.ISO_8859_1))) {
        str = in.readLine();
        while (str != null) {
            buff.append(str);
            str = in.readLine();
        }
    }

    return buff.toString();
}

From source file:de.micromata.genome.util.collections.NewPropertiesLineReader.java

public void read(InputStream is) throws RuntimeIOException {
    read(is, StandardCharsets.ISO_8859_1);
}

From source file:com.seleritycorp.common.base.http.client.HttpResponseStreamTest.java

@Test
public void testGetBodyIso8859_1() throws Exception {
    byte[] iso8859_1 = new byte[] { (byte) 0xe4, (byte) 0xfc, (byte) 0xdf, 0x21 };
    HttpResponseStream response = createHttpResponseStream(200, iso8859_1, StandardCharsets.ISO_8859_1);
    String actual = IOUtils.toString(response.getBodyAsStream(), StandardCharsets.ISO_8859_1);

    assertThat(actual).isEqualTo("!");
}