zoukankan      html  css  js  c++  java
  • 瑶光科技基站数据解析

    package com.ygkj.test;
    
    import java.io.*;
    import java.net.*;
    
    public class Test20171226 {
        private static final int PORT=9000;
        private static final String HOST="192.168.2.200";
        
        public static void main(String[] args) {
            test1();
        }
        
        public static void test1() {
            Socket socket = null;
            DataInputStream dis = null;
            InputStream istr = null;
            byte[] buffer = null;
            try {
                socket = new Socket(HOST,PORT);
                while(true) {
                    
                    istr = socket.getInputStream();
                    //dis = new DataInputStream(istr);
                    buffer = new byte[istr.available()];
                    while(istr.read(buffer)>0) {
                        //System.out.println("receive_msg:"+buffer);
                        printHexString(buffer);
                        System.out.println("");
                    }
                }
            }catch(Exception e) {
                e.printStackTrace();
            }
        }
        
        public static void printHexString(byte[] b) {
            String str = "";
            for(int i=0;i<b.length;i++) {
                String hex = Integer.toHexString(b[i]&0xFF);
                if(hex.length()==1) {
                    hex = '0'+hex;
                }
                str = str+hex.toUpperCase();
            }
            char[] strChar = str.toCharArray();
            for(char aa :strChar) {
                System.out.print(aa);
            }
        }
    
    }
  • 相关阅读:
    Java学习9
    Windows环境下实现WireShark抓取HTTPS
    WireShark新手使用教程
    charles使用教程
    charles
    知道做到
    Appium 自动化测试改造思路
    今日总结
    今日总结
    今日总结
  • 原文地址:https://www.cnblogs.com/herd/p/11830909.html
Copyright © 2011-2022 走看看