DICOM文件转16进制

    xiaoxiao2021-04-11  41

    话不多说直接上代码 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==15) { System.out.println(); }else{ System.out.print(", "); } } } }
    转载请注明原文地址: https://ju.6miu.com/read-666600.html

    最新回复(0)