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:MSUmpire.DIA.DIAPack.java

public static BufferedWriter get_file(final OutputFile f, final String filename) {
    final BufferedWriter bw = DIAPack.file_handlers.get(f);
    if (bw == null) {
        final BufferedWriter bw2;
        try {//from   w w  w .j  a  v  a  2 s.  com
            bw2 = Files.newBufferedWriter(Paths.get(filename), StandardCharsets.ISO_8859_1);
        } catch (final IOException ex) {
            throw new RuntimeException(ex);
        }
        DIAPack.file_handlers.put(f, bw2);
        return bw2;
    }
    return bw;
}

From source file:com.sonymobile.android.media.internal.ISOBMFFParser.java

private String readID3String(int frameSize) {
    String metadataString = null;
    try {//ww  w. j a  va  2s  .com
        int encoding = mDataSource.readByte();
        if (frameSize > 1) {
            if (encoding == 0) {
                // ISO 8859-1
                byte[] buffer = new byte[frameSize - 1];
                mDataSource.read(buffer);
                metadataString = new String(buffer, StandardCharsets.ISO_8859_1);
            } else if (encoding == 2) {
                // UTF-16
                int bom = mDataSource.readShort();
                byte[] buffer = new byte[frameSize - 3];
                short little_endian = (short) 0xFFFE;
                mDataSource.read(buffer);
                if (bom == little_endian) {
                    metadataString = new String(buffer, StandardCharsets.UTF_16LE);
                } else {
                    metadataString = new String(buffer, StandardCharsets.UTF_16BE);
                }
            } else if (encoding == 3) {
                // UTF-8
                byte[] buffer = new byte[frameSize - 1];
                mDataSource.read(buffer);
                metadataString = new String(buffer, StandardCharsets.UTF_8);
            } else {
                // UCS-2
                int bom = mDataSource.readShort();
                byte[] buffer = new byte[frameSize - 3];
                mDataSource.read(buffer);
                short little_endian = (short) 0xFFFE;
                if (bom == little_endian) {
                    for (int i = 0; i < buffer.length; i += 2) {
                        byte tempByte = buffer[i];
                        buffer[i] = buffer[i + 1];
                        buffer[i + 1] = tempByte;
                    }
                }
                metadataString = new String(buffer, "UCS-2");
            }
        }
    } catch (IOException e) {
        if (LOGS_ENABLED)
            Log.e(TAG, "IOEception reading ID3 string", e);
    }
    return metadataString;
}

From source file:faa.cucumber.pages.FaaHomePage.java

public void selectFromRoleTypeCode() {
    //String returnValue = "null";
    try {/*  w  w w  .jav  a 2s. c  o  m*/
        //I would prefer to read my file using NIO, which is faster
        Path pathToMyTextFile = Paths
                .get((System.getProperty("user.dir") + "/src/test/java/faa/utils/role_types.txt"));
        //Path pathToMyTextFile = Paths.get("C:/Users/jfrankl6/workspacex/faa-gradle-newtest/src/test/java/faa/utils/role_types.txt");
        //Then I would like to obtain the lines in Array, also I could have them available for process later
        List<String> linesInFile = Files.readAllLines(pathToMyTextFile, StandardCharsets.ISO_8859_1);
        //If I want to access a random element, I would use random methods to access a random index of the list and retrieve that element
        Random randomUtil = new Random();

        //I will use the formula for random and define the maximum (which will be the length of the array -1) and the minimum which will be zero
        //since the indexes are represented from 0 to length - 1
        int max = linesInFile.size() - 1;
        int min = 0;
        System.out.println("Role Code Random min-->" + max);
        System.out.println("Role Code Random max-->" + min);
        System.out.println("Role Code  Random linesInFile.size()-->" + linesInFile.size());

        //You can simplify this formula later, I'm just putting the whole thing
        int randomIndexForWord = randomUtil.nextInt((max - min + 1)) + min;

        //Here I get a random Noun
        String randomWord = linesInFile.get(randomIndexForWord);
        System.out.println("randomWord Random Role Types 4-->" + randomWord);
        //              System.out.println("returnValue Random Role Types -->" + returnValue);
        //              returnValue = randomWord;
        //              System.out.println("returnValue Random Role Types -->" + returnValue);
        Select dropDownList = new Select(inviteRoleCode);
        dropDownList.selectByVisibleText(randomWord);
        System.out.println("Selected from Role Type Drop Down List-->" + randomWord);
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    //         Select dropDownList = new Select(inviteRoleType);
    //         dropDownList.selectByVisibleText(roleType);
    //         System.out.println("Selected from Role Type Drop Down List-->" + roleType);
    //return returnValue;
}