原创
输出流
有哪些构造方法可以在参数上设置编码格式
PrintStream(File file, String csn)
PrintStream(String fileName, String csn)
PrintWriter(File file, String csn)
PrintWriter(String fileName, String csn)
(注:PrintWriter
类的构造方法可以接收OutputStream)OutputStreamWriter(OutputStream out, Charset cs)
(注:An OutputStreamWriter is a bridge from character streams to byte streams: Characters written to it are encoded into bytes using a specified charset. The charset that it uses may be specified by name or may be given explicitly, or the platform's default charset may be accepted.可知OutputStreamWriter
发挥了桥梁的作用)
输入流
有哪些构造方法可以在参数上设置编码格式
InputStreamReader(InputStream in, Charset cs)
Scanner(File source, String charsetName)
Scanner(InputStream source, String charsetName)
Scanner(Path source, String charsetName)
其他可以设置编码的方法
String(byte[] bytes, Charset charset
getBytes(Charset charset)
String的普通方法