FileInputStream的read(byte[] b) 问题。。 我用read(byte[] b)读二进制数据,然后再写到另一个文件中。read(byte[] b)读到源文件的最后部分,数组放不满,数组后半部分留有倒数第二次的数据,这两部分都被写进目标文件了。。这怎么解决一下?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你应该用这个方法读取:read(byte[] b, int off, int len)eg: OutputStream fos2 = new FileOutputStream("text2.txt",true); InputStream fis = new FileInputStream("test1.txt"); byte[] buffer = new byte[1024]; int length; while(-1 != (length=fis.read(buffer))){ System.out.println(new String(buffer, 0, length)); fos2.write(buffer, 0, length); } 有段代码想了好久都不懂.请各位帮忙一下 子窗口的问题 一道简单的JAVA测试题,你会选择哪个答案? 请注释一下下面的代码谢谢 如何让一个showMessageDialog现实10秒后自动关闭呢? 请大家帮忙,有关线程问题 请教这句话为什么是错的呢?多谢!(请举例说明) object obj=null;和object obj;有什么区别; 我要学习java,想问一些关于java的安装问题 Applet的问题!谢谢帮忙!! JComboBox 获取箭头部分或者如何为箭头部分添加监听事件? 新人,关于StringBuilder的equals方法,求大神指点一下
eg:
OutputStream fos2 = new FileOutputStream("text2.txt",true);
InputStream fis = new FileInputStream("test1.txt");
byte[] buffer = new byte[1024];
int length;
while(-1 != (length=fis.read(buffer))){
System.out.println(new String(buffer, 0, length));
fos2.write(buffer, 0, length);
}