Advertisement
Guest User

Untitled

a guest
May 20th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.18 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3.  
  4. public class Steg {
  5.  
  6.     public static void main(String[] args) {
  7.         File file = new File("/Users/Vinesh/Desktop/stego_ecg.txt");
  8.         String message = "";
  9.         try {
  10.             Scanner scan = new Scanner(file);
  11.             while (scan.hasNextDouble()) {
  12.                 // Conversion code by Mohammad Saidur Rahman on discussion board
  13.                 // Convert a double value into binary string
  14.                 double value = scan.nextDouble();
  15.                 String binaryValue = Long.toBinaryString(Double.doubleToRawLongBits(value));
  16.                 // Need to check if the length binaryValue is 64 bit or not
  17.                 // If the length is not 64 bit, fill with ZERO (0) at the left
  18.                 int length = binaryValue.length();
  19.                 for (int j = 0; j < 64 - length; j++) {
  20.                     binaryValue = "0" + binaryValue;
  21.                 }
  22.                 // Adds the LSB to an empty string for conversion later
  23.                 message += binaryValue.charAt(binaryValue.length() - 1);
  24.                 // Print 64 bit Binary String
  25.                 System.out.println(binaryValue);
  26.                
  27.             }
  28.         } catch (FileNotFoundException e) {
  29.             // TODO Auto-generated catch block
  30.             e.printStackTrace();
  31.         }
  32.         System.out.println("-----------------------------------");
  33.         System.out.println(message);
  34.     }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement