【java】获取当前环境属性及编码乱码示例

 package 字符编码;

 import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException; public class TestGetProperties {
public static void main(String[] args) throws UnsupportedEncodingException, IOException {
System.getProperties().list(System.out);//输出当前环境属性
File file=new File("D:"+File.separator+"test.txt");
OutputStream out=new FileOutputStream(file);
out.write("黄山黄河长江长城".getBytes("UTF-8"));//无乱码
out.write("黄山黄河长江长城".getBytes("ISO8859-1"));//有乱码
out.close();
}
}
上一篇:Jenkins配置从节点


下一篇:JDBC常用接口详解