将一个字节数组通过FileInputStream写到文件中,然后再用记事本打开和直接用String str = new String(byte[]);显示得不一样呢?求助啊!!!!
解决方案 »
- [*] 如何修改jar包里的文件?
- eclipse设置的一个小问题
- Jtree的问题???
- 求教高手,关于二进制的操作
- 急求解决方法,成功马上给分
- JAVA调用一个DLL的驱动程序
- 小菜一碟,来和大家讨论一下最佳算法,来者有分,答者重分,言出必行!2005.1.18日之前结帐~分数不够可再加!
- 在哪里可以下载到JBuilder8.0啊,
- 在使用中,经常出现提示为:java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]连接占线导致另一个 hstmt,是什么意思,怎样解
- 我有一个创意,是关于手机,掌上电脑等小型设备的,有高手可以与我联系,共同开发
- 关于初始化引用的疑问
- 求救大虾们,写的复制文件的程序问题到底出在哪里???
public static void main(String[] args) throws IOException {
byte[] msg = {13,14,15,10,13};
System.out.println(new String(msg));
File file = new File("D:\\wlt\\tmp", "file1.txt");
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
FileOutputStream stream = new FileOutputStream(file);
stream.write(msg);
stream.flush();
stream.close();
}
byte[] msg = {97,98,99};
System.out.println(new String(msg));
File file = new File("D:\\tmp", "file1.txt");
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
FileOutputStream stream = new FileOutputStream(file);
stream.write(msg);
stream.flush();
stream.close();
}
byte[] a="程序".getBytes();
//for(byte b:a){
//System.out.println("["+b+"]");
//}
// byte[] msg = {13,14,15,10,13};
// byte[] msg = {97,98,99};
System.out.println(new String(a));
File file = new File("D:\\tmp", "file1.txt");
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
FileOutputStream stream = new FileOutputStream(file);
stream.write(a);
stream.flush();
stream.close();
}
String msg = "13,14,15,10,13";
System.out.println(new String(msg));
File file = new File("D:\\wlt\\tmp", "file1.txt");
if(!file.getParentFile().exists()){
file.getParentFile().mkdirs();
}
FileOutputStream stream = new FileOutputStream(file);
stream.write(msg.getBytes());
stream.flush();
stream.close();
}
stream.write(msg.getBytes("utf-8"),"gbk");
如果还是乱码 就变这句试试