当前位置: 首页>>代码示例>>Java>>正文


Java StandardCharsets.ISO_8859_1属性代码示例

本文整理汇总了Java中java.nio.charset.StandardCharsets.ISO_8859_1属性的典型用法代码示例。如果您正苦于以下问题:Java StandardCharsets.ISO_8859_1属性的具体用法?Java StandardCharsets.ISO_8859_1怎么用?Java StandardCharsets.ISO_8859_1使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.nio.charset.StandardCharsets的用法示例。


在下文中一共展示了StandardCharsets.ISO_8859_1属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: entryPutAfterStaticArea

@Test
public void entryPutAfterStaticArea() {
    HeaderTable table = new HeaderTable(256);
    int idx = table.length() + 1;
    assertThrows(IllegalArgumentException.class, () -> table.get(idx));

    byte[] bytes = new byte[32];
    rnd.nextBytes(bytes);
    String name = new String(bytes, StandardCharsets.ISO_8859_1);
    String value = "custom-value";

    table.put(name, value);
    HeaderField f = table.get(idx);
    assertEquals(name, f.name);
    assertEquals(value, f.value);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:HeaderTableTest.java

示例2: readByteArray

/**
 * @param arr
 * @param offset
 * @throws NullPointerException
 * @throws IndexOutOfBoundsException
 */
public void readByteArray(byte[] arr, int offset) throws InvalidDataTypeException
{
    if (arr == null)
    {
        throw new NullPointerException("Byte array is null");
    }

    if ((offset < 0) || (offset >= arr.length))
    {
        throw new IndexOutOfBoundsException("Offset to byte array is out of bounds: offset = " + offset + ", array.length = " + arr.length);
    }

    //offset += ();
    text = new String(arr, offset, arr.length - offset - 4, StandardCharsets.ISO_8859_1);

    //text = text.substring(0, text.length() - 5);
    timeStamp = 0;

    for (int i = arr.length - 4; i < arr.length; i++)
    {
        timeStamp <<= 8;
        timeStamp += arr[i];
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:30,代码来源:ID3v2LyricLine.java

示例3: decodeHeader

public void decodeHeader(byte[] b)
{
    int packetType = b[FIELD_PACKET_TYPE_POS];
    logger.fine("packetType" + packetType);
    String vorbis = new String(b, FIELD_CAPTURE_PATTERN_POS, FIELD_CAPTURE_PATTERN_LENGTH, StandardCharsets.ISO_8859_1);
    if (packetType == VorbisPacketType.SETUP_HEADER.getType() && vorbis.equals(CAPTURE_PATTERN))
    {
        isValid = true;
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:10,代码来源:VorbisSetupHeader.java

示例4: stringWriteChunked

@Test
public void stringWriteChunked() {
    final int MAX_STRING_LENGTH = 8;
    final ByteBuffer bytes = ByteBuffer.allocate(MAX_STRING_LENGTH + 6);
    final CharBuffer chars = CharBuffer.allocate(MAX_STRING_LENGTH);
    final StringReader reader = new StringReader();
    final StringWriter writer = new StringWriter();
    for (int len = 0; len <= MAX_STRING_LENGTH; len++) {

        byte[] b = new byte[len];
        rnd.nextBytes(b);

        String expected = new String(b, StandardCharsets.ISO_8859_1); // reference string

        forEachSplit(bytes, (buffers) -> {
            writer.configure(expected, 0, expected.length(), false);
            boolean written = false;
            for (ByteBuffer buf : buffers) {
                int p0 = buf.position();
                written = writer.write(buf);
                buf.position(p0);
            }
            if (!written) {
                fail("please increase 'bytes' size");
            }
            reader.read(concat(buffers), chars);
            chars.flip();
            assertEquals(chars.toString(), expected);
            reader.reset();
            writer.reset();
            chars.clear();
            bytes.clear();
        });
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:35,代码来源:BinaryPrimitivesTest.java

示例5: testPrintAndExit

private static void testPrintAndExit() {
    String expected = "<e4>";
    String content = "";

    File file = new File("out.ps");
    if (!DEBUG) {
        file.deleteOnExit();
    }

    try (FileInputStream stream = new FileInputStream(file)) {
        byte[] data = new byte[(int) file.length()];
        stream.read(data);
        content = new String(data, StandardCharsets.ISO_8859_1);
    } catch (IOException ex) {
        ex.printStackTrace();
    }

    if (!content.contains(expected)) {
        System.err.println("FAIL");
        if (DEBUG) {
            System.err.println("printing content");
            System.err.println(content);
        }
        throw new RuntimeException("Expected <e4> to represent '\u00e4' but not found!");
    }
    System.err.println("SUCCESS");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:27,代码来源:PrintSEUmlauts.java

示例6: stringReadChunked

@Test
public void stringReadChunked() {
    final int MAX_STRING_LENGTH = 16;
    final ByteBuffer bytes = ByteBuffer.allocate(MAX_STRING_LENGTH + 6);
    final CharBuffer chars = CharBuffer.allocate(MAX_STRING_LENGTH);
    final StringReader reader = new StringReader();
    final StringWriter writer = new StringWriter();
    for (int len = 0; len <= MAX_STRING_LENGTH; len++) {

        byte[] b = new byte[len];
        rnd.nextBytes(b);

        String expected = new String(b, StandardCharsets.ISO_8859_1); // reference string

        boolean written = writer
                .configure(CharBuffer.wrap(expected), 0, expected.length(), false)
                .write(bytes);
        writer.reset();

        if (!written) {
            fail("please increase 'bytes' size");
        }
        bytes.flip();

        forEachSplit(bytes, (buffers) -> {
            for (ByteBuffer buf : buffers) {
                int p0 = buf.position();
                reader.read(buf, chars);
                buf.position(p0);
            }
            chars.flip();
            assertEquals(chars.toString(), expected);
            reader.reset();
            chars.clear();
        });

        bytes.clear();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:39,代码来源:BinaryPrimitivesTest.java

示例7: testCreateWithLanguageSet

@Test
public void testCreateWithLanguageSet() throws IOException {
  Path path = temp.getRoot().toPath().resolve("file");
  Files.write(path, "test".getBytes(StandardCharsets.ISO_8859_1));
  ClientInputFile file = new TestClientInputFile(path, true, StandardCharsets.ISO_8859_1, "cpp");

  InputFileBuilder builder = new InputFileBuilder(langDetection, metadata);
  SonarLintInputFile inputFile = builder.create(file);

  assertThat(inputFile.language()).isEqualTo("cpp");
  verifyZeroInteractions(langDetection);
}
 
开发者ID:instalint-org,项目名称:instalint,代码行数:12,代码来源:InputFileBuilderTest.java

示例8: getImageUrl

/**
 * @return the image url if there is otherwise return an empty String
 */
public String getImageUrl()
{
    if (isImageUrl())
    {
        return new String(getImageData(), 0, getImageData().length, StandardCharsets.ISO_8859_1);
    }
    else
    {
        return "";
    }
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:14,代码来源:MetadataBlockDataPicture.java

示例9: stringIdentity

@Test
public void stringIdentity() {
    final int MAX_STRING_LENGTH = 4096;
    ByteBuffer bytes = ByteBuffer.allocate(MAX_STRING_LENGTH + 6); // it takes 6 bytes to encode string length of Integer.MAX_VALUE
    CharBuffer chars = CharBuffer.allocate(MAX_STRING_LENGTH);
    StringReader reader = new StringReader();
    StringWriter writer = new StringWriter();
    for (int len = 0; len <= MAX_STRING_LENGTH; len++) {
        for (int i = 0; i < 64; i++) {
            // not so much "test in isolation", I know... we're testing .reset() as well
            bytes.clear();
            chars.clear();

            byte[] b = new byte[len];
            rnd.nextBytes(b);

            String expected = new String(b, StandardCharsets.ISO_8859_1); // reference string

            boolean written = writer
                    .configure(CharBuffer.wrap(expected), 0, expected.length(), false)
                    .write(bytes);

            if (!written) {
                fail("please increase 'bytes' size");
            }
            bytes.flip();
            reader.read(bytes, chars);
            chars.flip();
            assertEquals(chars.toString(), expected);
            reader.reset();
            writer.reset();
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:34,代码来源:BinaryPrimitivesTest.java

示例10: run

@Override
public void run() {
    byte[] buf = new byte[256];
    String s = "";
    try {
        while (true) {
            int n = is.read(buf);
            if (n == -1) {
                cleanup();
                return;
            }
            String s0 = new String(buf, 0, n, StandardCharsets.ISO_8859_1);
            s = s + s0;
            int i;
            while ((i=s.indexOf(CRLF)) != -1) {
                String s1 = s.substring(0, i+2);
                incoming.put(s1);
                if (i+2 == s.length()) {
                    s = "";
                    break;
                }
                s = s.substring(i+2);
            }
        }
    } catch (IOException |InterruptedException e1) {
        cleanup();
    } catch (Throwable t) {
        System.out.println("X: " + t);
        cleanup();
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:Server.java

示例11: ID3v1TagField

/**
 * Creates an instance.
 *
 * @param raw Raw byte data of the tagfield.
 * @throws UnsupportedEncodingException If the data doesn't conform "UTF-8" specification.
 */
public ID3v1TagField(final byte[] raw) throws UnsupportedEncodingException
{
    String field = new String(raw, StandardCharsets.ISO_8859_1);

    int i = field.indexOf('=');
    if (i == -1)
    {
        //Beware that ogg ID, must be capitalized and contain no space..
        this.id = "ERRONEOUS";
        this.content = field;
    }
    else
    {
        this.id = field.substring(0, i).toUpperCase();
        if (field.length() > i)
        {
            this.content = field.substring(i + 1);
        }
        else
        {
            //We have "XXXXXX=" with nothing after the "="
            this.content = "";
        }
    }
    checkCommon();
}
 
开发者ID:GlennioTech,项目名称:MetadataEditor,代码行数:32,代码来源:ID3v1TagField.java

示例12: encodeName

public static String encodeName ( String name ) {
    String fileName  = name + "-" + ( DateUtils.currentTimeString() );
    String userAgent = RequestUtils.getUserAgentHeader();
    if ( StringUtils.isNotBlank( userAgent ) && userAgent.contains( "Mozilla" ) ) {
        // Chrome, Firefox, Safari etc...
        fileName = new String( fileName.getBytes() , StandardCharsets.ISO_8859_1 );
    } else {
        try {
            fileName = URLEncoder.encode( fileName , StandardCharsets.UTF_8.name() );
        } catch ( UnsupportedEncodingException e ) {
            // ignore
        }
    }
    return fileName;
}
 
开发者ID:yujunhao8831,项目名称:spring-boot-start-current,代码行数:15,代码来源:Export.java

示例13: encodeEasyTransHeader

private String encodeEasyTransHeader(Map<String, Object> header) {
	return new String(Base64.getEncoder().encode(serializer.serialization(header)), StandardCharsets.ISO_8859_1);
}
 
开发者ID:QNJR-GROUP,项目名称:EasyTransaction,代码行数:3,代码来源:RestRibbonEasyTransRpcConsumerImpl.java

示例14: HtsTxtParser

HtsTxtParser(InputStream txtReader) throws IOException {
    this(new BufferedReader(new InputStreamReader(txtReader, StandardCharsets.ISO_8859_1)));
}
 
开发者ID:nla,项目名称:httrack2warc,代码行数:3,代码来源:HtsTxtParser.java

示例15: HtsDoitParser

HtsDoitParser(InputStream doitStream) throws IOException {
    this(new BufferedReader(new InputStreamReader(doitStream, StandardCharsets.ISO_8859_1)));
}
 
开发者ID:nla,项目名称:httrack2warc,代码行数:3,代码来源:HtsDoitParser.java


注:本文中的java.nio.charset.StandardCharsets.ISO_8859_1属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。