本文整理汇总了Java中sun.nio.cs.StreamEncoder类的典型用法代码示例。如果您正苦于以下问题:Java StreamEncoder类的具体用法?Java StreamEncoder怎么用?Java StreamEncoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StreamEncoder类属于sun.nio.cs包,在下文中一共展示了StreamEncoder类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Console
import sun.nio.cs.StreamEncoder; //导入依赖的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];
}
示例2: Console
import sun.nio.cs.StreamEncoder; //导入依赖的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];
}
示例3: OutputStreamWriter
import sun.nio.cs.StreamEncoder; //导入依赖的package包/类
/**
* Creates an OutputStreamWriter that uses the default character encoding.
*
* @param out An OutputStream
*/
public OutputStreamWriter(OutputStream out) {
super(out);
try {
se = StreamEncoder.forOutputStreamWriter(out, this, (String)null);
} catch (UnsupportedEncodingException e) {
throw new Error(e);
}
}
示例4: OptimizedInterceptedOutputStreamWriter
import sun.nio.cs.StreamEncoder; //导入依赖的package包/类
OptimizedInterceptedOutputStreamWriter(OptimizedInterceptedFileOutputStream outputStream) {
super(outputStream);
this.outputStream = outputStream;
try {
this.encoder = StreamEncoder.forOutputStreamWriter(outputStream, this, (String)null);
} catch (UnsupportedEncodingException e) {
throw new Error(e);
}
}
示例5: OutputStreamWriter
import sun.nio.cs.StreamEncoder; //导入依赖的package包/类
/**
* Creates an OutputStreamWriter that uses the default character encoding.
*
* @param out An OutputStream
*/
public OutputStreamWriter(OutputStream out) {
super(out);
try {
se = StreamEncoder.forOutputStreamWriter(out, this, (String)null);
} catch (UnsupportedEncodingException e) {
throw new Error(e);
}
}
示例6: GZipResponseWriter
import sun.nio.cs.StreamEncoder; //导入依赖的package包/类
public GZipResponseWriter(OutputStream out, String charsetName)
throws UnsupportedEncodingException {
super(out);
se = StreamEncoder.forOutputStreamWriter(out, this, charsetName);
}
示例7: newWriter
import sun.nio.cs.StreamEncoder; //导入依赖的package包/类
/**
* Constructs a writer that encodes characters using the given encoder and
* writes the resulting bytes to the given channel.
*
* <p> The resulting stream will contain an internal output buffer of at
* least <tt>minBufferCap</tt> bytes. The stream's <tt>write</tt> methods
* will, as needed, flush the buffer by writing bytes to the underlying
* channel; if the channel is in non-blocking mode when bytes are to be
* written then an {@link IllegalBlockingModeException} will be thrown.
* The resulting stream will not otherwise be buffered. Closing the stream
* will in turn cause the channel to be closed. </p>
*
* @param ch
* The channel to which bytes will be written
*
* @param enc
* The charset encoder 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 writer
*/
public static Writer newWriter(final WritableByteChannel ch,
final CharsetEncoder enc,
final int minBufferCap)
{
checkNotNull(ch, "ch");
return StreamEncoder.forEncoder(ch, enc.reset(), minBufferCap);
}