當前位置: 首頁>>代碼示例>>Java>>正文


Java Charset.decode方法代碼示例

本文整理匯總了Java中java.nio.charset.Charset.decode方法的典型用法代碼示例。如果您正苦於以下問題:Java Charset.decode方法的具體用法?Java Charset.decode怎麽用?Java Charset.decode使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.charset.Charset的用法示例。


在下文中一共展示了Charset.decode方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: decode

import java.nio.charset.Charset; //導入方法依賴的package包/類
public void decode() throws MAPException {

        if (this.isDecoded)
            return;
        this.isDecoded = true;

        this.decodedMessage = null;

        if (this.encodedData == null)
            throw new MAPException("Error decoding a text from Sms CommandData: encodedData field is null");

        // TODO: what is an encoding algorithm ?
        Charset chs = Charset.forName("US-ASCII");
        byte[] buf = this.encodedData;
        ByteBuffer bb = ByteBuffer.wrap(buf);
        CharBuffer bf = chs.decode(bb);
        this.decodedMessage = bf.toString();
    }
 
開發者ID:RestComm,項目名稱:phone-simulator,代碼行數:19,代碼來源:CommandDataImpl.java

示例2: getCharSequence

import java.nio.charset.Charset; //導入方法依賴的package包/類
/**
    * Converts an input file stream into a char sequence.
    *
    * @throws IOException
    */
   static CharBuffer getCharSequence(final FileInputStream stream, Charset encoding) throws IOException {
       FileChannel channel = stream.getChannel();
       ByteBuffer bbuf = ByteBuffer.allocate((int) channel.size());
       try {
           channel.read(bbuf, 0);
       } catch (ClosedByInterruptException cbie) {
           return null;        //this is actually okay
       } finally {
           channel.close();
       }
       bbuf.rewind();
       CharBuffer cbuf = encoding.decode(bbuf);

       return cbuf;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:Utils.java

示例3: run

import java.nio.charset.Charset; //導入方法依賴的package包/類
public void run() {
    while (true) {
        try {
            mChannel.read(mReceiveBuf);
            mReceiveBuf.flip();
            Charset charset = Charset.forName("ASCII");
            CharBuffer cbuf = charset.decode(mReceiveBuf);
            String result = cbuf.toString();
            parseAndCallback(result);
            mReceiveBuf.clear();
        } catch (Exception e) {
            disconnect();
            //TODO: implement some handling here!
            break;
        }
    }
}
 
開發者ID:voroshkov,項目名稱:Chorus-RF-Laptimer,代碼行數:18,代碼來源:UDPService.java

示例4: decode

import java.nio.charset.Charset; //導入方法依賴的package包/類
/**
 * Convert string from UTF-7 characters
 * 
 * @param string Input string for decoding
 * @return Decoded string
 */
public static String decode(String string, String charsetName)
{
    if (string.length() <= 1)
    {
        return string;
    }
    CharsetProvider provider = new CharsetProvider();
    Charset charset = provider.charsetForName(charsetName);
    CharBuffer charBuffer = charset.decode(ByteBuffer.wrap(string.getBytes()));
    return charBuffer.toString();
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:18,代碼來源:Utf7.java

示例5: convert

import java.nio.charset.Charset; //導入方法依賴的package包/類
protected static Object convert ( final byte[] data, final Charset charset )
{
    if ( data == null )
    {
        return null;
    }

    if ( charset == null )
    {
        return data;
    }

    final CharBuffer cb = charset.decode ( ByteBuffer.wrap ( data ) );
    return cb.toString ();
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:16,代碼來源:AbstractScheduledInput.java

示例6: toString

import java.nio.charset.Charset; //導入方法依賴的package包/類
/** Consumes remaining contents of this object, and returns them as a string. */
public String toString() {
  Charset cset = Charset.forName("UTF-8");
  CharBuffer cb = cset.decode(ByteBuffer.wrap(this.toArray()));
  return cb.toString();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:7,代碼來源:ByteIterator.java


注:本文中的java.nio.charset.Charset.decode方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。