How to get characters to a string in Java? -


I have a text file that has hexadecimal values ​​like "Captured Network Packets Headers" ...

  FC-C8-97-62-88-5F-74-DE-2B-C8-C7-E5-08-00-45-00-00-28-4E-C4 -40-00 -80-06-BD-65-C0-A8-01-03-AD-C2-7F-38-C9-96-01-BB-F8-01-7F-5F-B6-8A-15 -22-50 -10-40-42-72-8C-00-00.   

I need to convert them into decimal values ​​... I was very few here ..

  InputStream input = new FileInputStream ("data. Txt "); OutputStream Output = New FileOutputStream ("converteddata.txt"); Int data = input Reed (); While (data! = -1) {char ch = (four) data; Output.write (ch); Data = input.read (); } Input.close (); Output.close ();   

Now, my problem is ... How to get each hexadecimal string in which there will be '2' characters? (Such as "edi" or 5f etc.) to convert them into successive values.

I know that C ++ is not a function "fgetc ()" ..? I need a similar solution. Can anyone recommend a good solution ..? (Sorry, I'm starting for Java, but C ++ knows very well) Thanks in advance.

Here is a sample code. Please customize for real-time use.

  Public static zero main (string [] args throws IOException {output output output = new FileOutputStream ("converteddata.txt"); Bufferbrd br = new buffed reader (new filereader (new file ("data .ttt")); String r = null; (String = string: str) {long l = long parcelong (string.trim () (= (r = br.readline ())! = Null {strings [] str = r.split ("-"); , 16); output.write (String.valueOf (L) .getBytes ()); output.write ("\ n" .getBytes ());}} Br.close (); output.close ();} < / Code>   

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -