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


Java StreamDecoder类代码示例

本文整理汇总了Java中sun.nio.cs.StreamDecoder的典型用法代码示例。如果您正苦于以下问题:Java StreamDecoder类的具体用法?Java StreamDecoder怎么用?Java StreamDecoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Console

import sun.nio.cs.StreamDecoder; //导入依赖的package包/类
private Console() {
    readLock = new Object();
    writeLock = new Object();
    String csname = encoding();
    if (csname != null) {
        try {
            cs = Charset.forName(csname);
        } catch (Exception x) {}
    }
    if (cs == null)
        cs = Charset.defaultCharset();
    out = StreamEncoder.forOutputStreamWriter(
              new FileOutputStream(FileDescriptor.out),
              writeLock,
              cs);
    pw = new PrintWriter(out, true) { public void close() {} };
    formatter = new Formatter(out);
    reader = new LineReader(StreamDecoder.forInputStreamReader(
                 new FileInputStream(FileDescriptor.in),
                 readLock,
                 cs));
    rcb = new char[1024];
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:24,代码来源:Console.java

示例2: Console

import sun.nio.cs.StreamDecoder; //导入依赖的package包/类
private Console() {
       readLock = new Object();
       writeLock = new Object();    
       String csname = encoding();
       if (csname != null) {
           try {
               cs = Charset.forName(csname);
           } catch (Exception x) {}
       }
       if (cs == null)
           cs = Charset.defaultCharset();
       out = StreamEncoder.forOutputStreamWriter(
                 new FileOutputStream(FileDescriptor.out),
	  writeLock, 
	  cs);
       pw = new PrintWriter(out, true) { public void close() {} };
       formatter = new Formatter(out);
       reader = new LineReader(StreamDecoder.forInputStreamReader(
	     new FileInputStream(FileDescriptor.in),
	     readLock, 
	     cs));
rcb = new char[1024];
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:24,代码来源:Console.java

示例3: InputStreamReader

import sun.nio.cs.StreamDecoder; //导入依赖的package包/类
/**
 * Creates an InputStreamReader that uses the default charset.
 *
 * @param  in   An InputStream
 */
public InputStreamReader(InputStream in) {
    super(in);
    try {
        sd = StreamDecoder.forInputStreamReader(in, this, (String)null); // ## check lock object
    } catch (UnsupportedEncodingException e) {
        // The default encoding should always be available
        throw new Error(e);
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:15,代码来源:InputStreamReader.java

示例4: HttpReader

import sun.nio.cs.StreamDecoder; //导入依赖的package包/类
HttpReader(InputStream in, String charsetName) throws UnsupportedEncodingException {
    super(in);

    this.sd = StreamDecoder.forInputStreamReader(in, this, Preconditions.checkNotNull(charsetName, "charsetName"));

    try {
        Field bb = sd.getClass().getDeclaredField("bb");
        bb.setAccessible(true);
        Object o = bb.get(sd);

        this.byteBuffer = (ByteBuffer) o;
    } catch (NoSuchFieldException | IllegalAccessException e) {
        e.printStackTrace();
    }
}
 
开发者ID:JackWhite20,项目名称:Cobra,代码行数:16,代码来源:HttpReader.java

示例5: OptimizedInterceptedInputStreamReader

import sun.nio.cs.StreamDecoder; //导入依赖的package包/类
public OptimizedInterceptedInputStreamReader(OptimizedInterceptedFileInputStream inputStream) {
    super(inputStream);
    this.inputStream = inputStream;

    try {
        this.decoder = StreamDecoder.forInputStreamReader(inputStream, this, (String)null);
    } catch (UnsupportedEncodingException e) {
        throw new Error(e);
    }
}
 
开发者ID:uwdb,项目名称:pipegen,代码行数:11,代码来源:OptimizedInterceptedInputStreamReader.java

示例6: InputStreamReader

import sun.nio.cs.StreamDecoder; //导入依赖的package包/类
/**
    * Creates an InputStreamReader that uses the default charset.
    *
    * @param  in   An InputStream
    */
   public InputStreamReader(InputStream in) {
super(in);
       try {
    sd = StreamDecoder.forInputStreamReader(in, this, (String)null); // ## check lock object
       } catch (UnsupportedEncodingException e) {
    // The default encoding should always be available
    throw new Error(e);
}
   }
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:15,代码来源:InputStreamReader.java

示例7: newReader

import sun.nio.cs.StreamDecoder; //导入依赖的package包/类
/**
 * Constructs a reader that decodes bytes from the given channel using the
 * given decoder.
 *
 * <p> The resulting stream will contain an internal input buffer of at
 * least <tt>minBufferCap</tt> bytes.  The stream's <tt>read</tt> methods
 * will, as needed, fill the buffer by reading bytes from the underlying
 * channel; if the channel is in non-blocking mode when bytes are to be
 * read then an {@link IllegalBlockingModeException} will be thrown.  The
 * resulting stream will not otherwise be buffered, and it will not support
 * the {@link Reader#mark mark} or {@link Reader#reset reset} methods.
 * Closing the stream will in turn cause the channel to be closed.  </p>
 *
 * @param  ch
 *         The channel from which bytes will be read
 *
 * @param  dec
 *         The charset decoder to be used
 *
 * @param  minBufferCap
 *         The minimum capacity of the internal byte buffer,
 *         or <tt>-1</tt> if an implementation-dependent
 *         default capacity is to be used
 *
 * @return  A new reader
 */
public static Reader newReader(ReadableByteChannel ch,
                               CharsetDecoder dec,
                               int minBufferCap)
{
    checkNotNull(ch, "ch");
    return StreamDecoder.forDecoder(ch, dec.reset(), minBufferCap);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:Channels.java


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