从图片拿到byte[],然后调用byte[]转16进制字符的方法就行了
private static String byte2hex(byte[] b) {
         String hs = "";
         String stmp = "";
         for (int n = 0; n < b.length; n++) {
             stmp = (java.lang.Integer.toHexString(b[n] & 0XFF));
             if (stmp.length() == 1) {
                 hs = hs + "0" + stmp;
             } else {
                 hs = hs + stmp;
             }
         }
         return hs.toUpperCase();
     }

解决方案 »

  1.   

    首先你要获得图片的byte,然后通过如下方法:  byte[]b=new byte[]{127,99,98};
     String hex="0123456789abcdef";
     String r="";
     for (int i = 0; i < b.length; i++) {
    r+=String.valueOf( hex.charAt((b[i]>>4)&0xf))+
    String.valueOf( hex.charAt((b[i]>>0)&0xf));
     }
     System.out.println(r);其中的b变量是你需要转换的突破字节
      

  2.   

    public static void main(String []args) throws Exception{
    DataInputStream in = new DataInputStream(new FileInputStream("C:/Users/Public/Pictures/Sample Pictures/Autumn Leaves.jpg"));
    PrintStream out = new PrintStream(new FileOutputStream("d:/img.txt"));
    while(in.available() > 0){
    out.printf("%x", in.read());
    }
    out.close();
    in.close();

    }
      

  3.   


    public static void main(String[] args) throws Exception {
    FileInputStream fileInputStream = new FileInputStream(new File("test.png"));
    FileChannel fileChannel = fileInputStream.getChannel();

    ByteBuffer buffer = ByteBuffer.allocate(1024);
    StringBuffer sb = new StringBuffer();
    while(fileChannel.read(buffer)!=-1){
    buffer.flip();
    while(buffer.hasRemaining()){
    sb.append(Integer.toHexString(buffer.get()));
    }
    buffer.clear();
    }
    System.out.print(sb.toString().toUpperCase());
    fileChannel.close();
    fileInputStream.close();
    }
      

  4.   

    一个例子:package test;import java.io.File;
    import java.io.IOException;import javax.xml.parsers.*;
    import org.w3c.dom.*;
    import org.xml.sax.SAXException;public class Dom{    public static void main(String[] args) {
            try {
                File file = new File("D:\\dom.xml");
                DocumentBuilderFactory dobf = DocumentBuilderFactory.newInstance();
                DocumentBuilder db = dobf.newDocumentBuilder();
                Document dc=db.parse(file);
                NodeList ndl=dc.getElementsByTagName("VALUE");
                for(int i=0;i<ndl.getLength();i++){
                    String noum=dc.getElementsByTagName("NO").item(i).getTextContent();
                    System.out.println(noum);
                    String add=dc.getElementsByTagName("ADDR").item(i).getTextContent();
                    System.out.println(add);
                }
            } catch (ParserConfigurationException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }catch(SAXException e){
                e.printStackTrace();
            }catch(IOException e){
                e.printStackTrace();
            }
        }
    }
    <?xml version="1.0" encoding="UTF-8"?> 
    <RESULT>
    <VALUE> 
    <NO>A1234</NO>
    <ADDR>深圳XX</ADDR>
    </VALUE>
    <VALUE> 
    <NO>B1234</NO> 
    <ADDR>珠海XXX</ADDR>
    </VALUE>
    </RESULT>
      

  5.   

    不小心搜了个在线转换的...
      哈哈http://dancewithnet.com/lab/2009/data-uri-mhtml/create.php