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0 1 1 1 1
0 1 0 0 1 1 1 0
0 0 0 0 0 0 0 0
0 1 0 0 1 1 0 1
0 0 1 1 0 0 1 0
0 0 1 0 0 0 1 1
0 0 1 1 0 0 1 1
1. 1 1 1 1 0 1 1
0 1 1 1 0 0 0 1
0 1 0 0 0 1 1 0
1. 1 0 1 0 1 0 0
1. 0 0 1 1 1 1 0
1. 0 0 0 1 1 0 0
0 0 1 1 0 0 0 1
1. 0 1 1 1 0 0 1
0 0 1 1 0 0 1 0
1. 1 1 0 0 1 1 0
1. 1 1 0 1 1 1 0
1. 1 1 1 0 0 1 1
1. 1 1 0 1 1 1 0
0 0 0 1 0 1 1 0
0 1 0 0 1 1 0 1
0 0 0 1 1 1 1 1
1. 1 0 1 0 0 1 0
1. 1 0 1 1 0 0 1
0 1 0 0 0 1 0 0
1. 0 1 0 1 0 0 0
1. 1 1 0 0 1 0 0
0 1 0 0 0 0 0 1
1. 0 0 1 1 1 0 0
1. 0 1 0 1 0 0 1
0 0 0 0 1 1 0 1
0 0 1 0 1 1 0 1
0 0 1 0 0 1 1 0
0 1 0 0 1 0 0 0
0 1 1 1 1 0 1 0
0 0 1 0 1 0 0 0
1. 0 0 1 0 1 1 0
0 0 0 0 0 1 1 1
1. 1 1 1 0 1 0 1
0 0 0 1 0 0 0 0
0 1 1 0 1 0 1 0
1. 0 1 1 1 1 1 1
1. 0 0 0 1 0 1 0
0 1 1 1 1 1 0 0
One system of steganography is "Least Significant Bit Insertion" which hides information by manipulating the least significant bit of bytes. The file binary.txt contains 800 lines representing bytes (one byte per line, each bit represented by a 0 or 1). You are to write a program (name your file Isbi_yourlnitials.java) that will isolate the least significant bit on each line of the file binary.txt and write those bits, eight per line, to a new file (name the file stage.txt) MY ORIGINAL INSTRUCTIONS WERE IN ERROR, THE OUTPUT FILE SHOULD BE BELOW: Given the input file above the lines of the output file would be 11011011 01100001 10001100 10001001 11011101 01001101 00101111 00001100 01001101 00010111 00000110 0100Explanation / Answer
import java.io.*;
import java.util.*;
public class Demo247{
public static void main(String[] args){
try {
FileInputStream fin = new FileInputStream("Binary.txt");
FileOutputStream fout = new FileOutputStream("stage.txt");
PrintWriter pw = new PrintWriter(fout);
Scanner fc = new Scanner(fin);
String str = "";
int count = 0;
while(fc.hasNextLine()){
String line = fc.nextLine();
//pw.println(line);
str = str + line.charAt(line.length()-1);
count++;
if (count == 8){
pw.println(str);
str = "";
count = 0;
}
}
fc.close();
pw.println(str);
pw.close();
//fout.close();
}
catch(Exception e){
e.printStackTrace();
}
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.