当前位置: 首页>>代码示例>>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;未经允许,请勿转载。