Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

how to show the hex detail of a file in java

//Just some image on my hard drive
File file = new File("C:Users\%username%PicturesMemesWhat_If_I_Told_You.jpg");
StringBuilder builder = new StringBuilder();
try {
    FileInputStream fin = new FileInputStream(file);
    byte[] buffer = new byte[1024];
    int bytesRead = 0;
    while((bytesRead = fin.read(buffer)) > -1)
        for(int i = 0; i < bytesRead; i++)
            builder.append(String.format("%02x", buffer[i] & 0xFF)).append(i != bytesRead - 1 ? " " : "");
} catch (IOException e) {
    e.printStackTrace();
}
System.out.println(builder.toString());
Comment

PREVIOUS NEXT
Code Example
Java :: Read array of characters from space separated values in java 
Java :: android api 21 join list of strings 
Java :: java destroy object 
Java :: how to make a ordering system in microsoft visual basic 2010 express console application 
Java :: https://java2blog.com/java-program-count-number-words-string/ 
Java :: how to shorten if else if and else in java 
Java :: java log4j2 load configuration 
Java :: change password swing gui 
Java :: class generique java 
Java :: convertBirthDay java 
Java :: Android popBackStack to specific fragment 
Java :: change button background drawable in code 
Java :: concatenar java 
Java :: java unshift 
Java :: clear datepicker javafx 
Java :: spring core xml configuration for collection using constructor 
Java :: jsp form upload file 
Java :: java formatted string input 
Java :: what is a literal in java 
Java :: break statement in Java switch...case 
Java :: Sling authentication handler example 
Java :: Small Change 
Java :: square operator java 
Java :: java program for calendar using applet 
Java :: read java reader 
Java :: iterade dict javacirpt 
Java :: viewResolver 
Java :: binary search tree 
Java :: method in java 
Java :: java indexof not found 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =