Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to read server binaries in java

Shulou Source: shulou.com Published: 2022-06-02 08:26:45 10月30日 Update

This article shows you how to read the server binaries in java, which is concise and easy to understand, which will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

Public static List dataInputStream (String filepath) throws IOException {/ / File file = new File (filepath); / / DataInputStream dps = new DataInputStream (new FileInputStream (file)); URL url = new URL (filepath); URLConnection conn = url.openConnection (); InputStream stream = conn.getInputStream (); DataInputStream dps = new DataInputStream (stream); StringBuilder hexData = new StringBuilder (); byte bt = 0There / long fileLength = file.length () Long fileLength = conn.getContentLength (); / / long fileLength = url.getFile (). Length (); System.out.println (fileLength); List fileContent = new ArrayList (); for (int I = 0; I < fileLength; iTunes +) {/ / only 254characters per line if (I% 127= = 0) {fileContent.add (hexData.toString ()) HexData = new StringBuilder ();} bt = dps.readByte (); / / returns a string representation as a hexadecimal unsigned integer. String str = Integer.toHexString (bt); if (str.length () = = 8) {/ / remove the complement f str = str.substring (6);} if (str.length () = = 1) {str = "0" + str;} hexData.append (str.toUpperCase ()) } fileContent.add (hexData.toString ()); return fileContent;} the above is how to read the server binaries in java. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Binary file server service content character form skill knowledge concise concise hexadecimal string that is integers articles more symbols articles industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Technology Apple Shulou Tech Info macOS Linux