62,614
社区成员
发帖
与我相关
我的任务
分享
FFD8FFE000104A46494600010100000000000000FFDB004300100B0C0E0C0A100E0D0E1211101318281A181616183123251D283A333D3C3933383740485C4E404457453738506D51575F626768673E4D71797064785C656763FFDB0043011112121815182F1A1A2F63423842636363636363636363636363636363636363636363
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>
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();
}
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();
}
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);
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();
}