DICOM文件转16进制

版权声明:作者:她如花似玉 转载请标明出处,原文地址: http://blog.csdn.net/qq_32566003 https://blog.csdn.net/qq_32566003/article/details/70157929
话不多说直接上代码
package com.cn;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;


public class text {
	   static FileInputStream input;
	    static byte[] b;
	public static void main(String[] args) {
		 try {
	            File file = new File("C:/Users/software/Desktop/DCM (1)/011958333339.dcm");
	            input = new FileInputStream(file);
	            b = new byte[(int) file.length()];
	            input.read(b);
	        } catch (FileNotFoundException e) {
	            e.printStackTrace();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        init();
	}
	public static void init(){
		System.out.println("b.length="+b.length);
        for (int i =0;i<10000;i++) {
        if (b[i]<0) {
                int temp=b[i]+256;
                System.out.print(Integer.toHexString(temp));
            }else{
                System.out.print(Integer.toHexString(b[i]));
            }

            if (i%16==15) {
                System.out.println();
            }else{
                System.out.print(", ");
            }
        }
    }
}


猜你喜欢

转载自blog.csdn.net/qq_32566003/article/details/70157929