Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.Scanner;
- public class Steg {
- public static void main(String[] args) {
- File file = new File("/Users/Vinesh/Desktop/stego_ecg.txt");
- String message = "";
- try {
- Scanner scan = new Scanner(file);
- while (scan.hasNextDouble()) {
- // Conversion code by Mohammad Saidur Rahman on discussion board
- // Convert a double value into binary string
- double value = scan.nextDouble();
- String binaryValue = Long.toBinaryString(Double.doubleToRawLongBits(value));
- // Need to check if the length binaryValue is 64 bit or not
- // If the length is not 64 bit, fill with ZERO (0) at the left
- int length = binaryValue.length();
- for (int j = 0; j < 64 - length; j++) {
- binaryValue = "0" + binaryValue;
- }
- // Adds the LSB to an empty string for conversion later
- message += binaryValue.charAt(binaryValue.length() - 1);
- // Print 64 bit Binary String
- System.out.println(binaryValue);
- }
- } catch (FileNotFoundException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- System.out.println("-----------------------------------");
- System.out.println(message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement