當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。