读书人

读取图片最后二个字节码

发布时间: 2012-08-31 12:55:03 作者: rapoo

读取图片最后2个字节码

public static void main(String[] args) {File file=new File("D:/preparedSource/2/12345678901420111203210722.jpg");RandomAccessFile randomfile=null;int result=0;long len;String str="";try {randomfile=new RandomAccessFile(file,"r");len=randomfile.length();randomfile.seek(len-2);while((result=randomfile.read())!=-1){str += Integer.toHexString(result & 0xff);}System.out.println(str);} catch (FileNotFoundException e) {// TODO Auto-generated catch blocke.printStackTrace();} catch (IOException e) {// TODO Auto-generated catch blocke.printStackTrace();}

?

读书人网 >编程

热点推荐