栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Java技能树-IO-InputStreamReader/OutputStreamWriter

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java技能树-IO-InputStreamReader/OutputStreamWriter

1 需求


2 接口

Class InputStreamReader

java.lang.Object 
        java.io.Reader 
                java.io.InputStreamReader 

  • Constructor Detail
    • public InputStreamReader(InputStream in)
    • public InputStreamReader(InputStream in, String charsetName) throws UnsupportedEncodingException
    • public InputStreamReader(InputStream in, Charset cs)
    • public InputStreamReader(InputStream in, CharsetDecoder dec)
  • Method Detail
    • public String getEncoding()
    • public int read() throws IOException
    • public int read(char[] cbuf, int offset, int length) throws IOException
    • public boolean ready() throws IOException
    • public void close() throws IOException

Class OutputStreamWriter

java.lang.Object 
        java.io.Writer 
                java.io.OutputStreamWriter 

  • Constructor Detail
    • public OutputStreamWriter(OutputStream out, String charsetName) throws UnsupportedEncodingException
    • public OutputStreamWriter(OutputStream out)
    • public OutputStreamWriter(OutputStream out, Charset cs)
    • public OutputStreamWriter(OutputStream out, CharsetEncoder enc)
  • Method Detail
    • public String getEncoding()
    • public void write(int c) throws IOException
    • public void write(char[] cbuf, int off, int len) throws IOException
    • public void write(String str, int off, int len) throws IOException
    • public void flush() throws IOException
    • public void close() throws IOException

3 示例代码

示例代码:判断cmd命令行编码格式:GBK

import java.io.IOException;
import java.io.InputStreamReader;

public class Test {
    public static void main(String[] args) throws IOException {
        InputStreamReader reader = new InputStreamReader(Runtime.getRuntime().exec("cmd /c dir").getInputStream());
        System.out.println(reader.getEncoding());
    }
}


4 参考资料

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/924995.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号