二进制文件内容的读取,转化与写入(急) 顶一下,请大家帮帮忙,提点建议 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 程序写的差不多,只要加上charset就行了。import java.io.RandomAccessFile;public class TestRead { public static void main(String[] args) { //todo:测试以二进制方式读文件,先测试读二进制文件. try { RandomAccessFile in = new RandomAccessFile("c:\\test.JPG", "r"); byte[] result = new byte[(int)in.length()]; in.readFully(result); System.out.println(String.valueOf((int)in.length())); System.out.println(String.valueOf(result.length)); // in.close(); String strTmp =new String(result, "ISO-8859-1"); System.out.println(String.valueOf(strTmp.length()));// System.out.println(strTmp); System.out.println("in.length"+in.length()); byte[] result1 = new byte[(int)in.length()]; result1 = strTmp.getBytes("ISO-8859-1"); RandomAccessFile inOut = new RandomAccessFile("c:\\test1.JPG", "rw"); inOut.write(result1); System.out.println(String.valueOf(result1.length)); in.close(); inOut.close(); System.out.println("ok,just copy complete"); //in.read(result); } catch(Exception ex) { } }} Socket阻塞的问题 java swing 问题 如何设计时间日期类的hashcode() 麻烦大家帮我看个简单的问题 想知道大家都用那个版本的插件 有关编码问题,急请高手帮忙 问题五:abstract修饰符的含义? 请问如何将Image中的数据导出到数组? 请教:谁能解释一下Serializable接口及serialVersionUID常量的用法? 请教JAVA的一个简单问题,急!!! 了解软件测试的高手请进?您的回答可能对我一生影响。 如何在单元级别控制绘制器,编辑器?
public class TestRead { public static void main(String[] args) { //todo:测试以二进制方式读文件,先测试读二进制文件.
try
{
RandomAccessFile in = new RandomAccessFile("c:\\test.JPG", "r");
byte[] result = new byte[(int)in.length()];
in.readFully(result);
System.out.println(String.valueOf((int)in.length()));
System.out.println(String.valueOf(result.length));
// in.close();
String strTmp =new String(result, "ISO-8859-1");
System.out.println(String.valueOf(strTmp.length()));
// System.out.println(strTmp);
System.out.println("in.length"+in.length());
byte[] result1 = new byte[(int)in.length()];
result1 = strTmp.getBytes("ISO-8859-1");
RandomAccessFile inOut = new RandomAccessFile("c:\\test1.JPG", "rw");
inOut.write(result1);
System.out.println(String.valueOf(result1.length));
in.close();
inOut.close();
System.out.println("ok,just copy complete");
//in.read(result); }
catch(Exception ex)
{ }
}
}