Last active
August 15, 2018 22:54
-
-
Save kurtkaiser/2c4df3c77b8be04a5120de4ad10f01da to your computer and use it in GitHub Desktop.
This was an assignment for an advance java class at my local community college. I was asked to get the Least Significant Bit from a text file of binary numbers. Then output the last bit of each line, the LSB, to a new text file. Each line of the new file needed to be eight characters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Kurt Kaiser | |
CTIM 168 | |
07.28.2018 | |
Homework: Steganography | |
Least Significant Bit Insertion | |
*/ | |
import java.io.*; | |
import java.util.Scanner; | |
public class lsbi_KK { | |
public static void main(String[] args) { | |
//File stage = new File ("stage.txt"); | |
String fileName = "stage.txt"; | |
PrintWriter outputStream = null; | |
String[] data = new String[100]; | |
String line = ""; | |
int count = 0; | |
try { | |
Scanner inputStream = new Scanner(new File("binary.txt")); | |
outputStream = new PrintWriter(fileName); | |
while (inputStream.hasNextLine()) { | |
// Scan each line of file into a string array | |
data[count] = inputStream.nextLine(); | |
// Get last character of each line and add to string line | |
line += data[count].charAt(14); | |
// Output to document once line is 8 characters | |
if ((count+1) % 8 == 0) { | |
outputStream.println(line); | |
line = ""; | |
} | |
count++; | |
} | |
} catch (FileNotFoundException e){ | |
System.out.println("Error opening the file " + fileName); | |
System.exit(0); | |
} | |
// Output final line to the file, in case final line not 8 characters | |
outputStream.println(line); | |
outputStream.close(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 1 0 1 1 0 1 1 | |
1 1 0 0 1 0 0 1 | |
1 1 0 1 1 1 0 0 | |
1 0 1 0 0 0 1 1 | |
0 1 0 0 0 0 0 1 | |
1 1 0 1 0 1 0 0 | |
0 1 1 1 1 0 0 1 | |
1 1 1 0 0 1 1 1 | |
1 1 0 0 0 0 1 0 | |
1 0 0 1 0 0 1 1 | |
1 1 0 1 0 0 1 1 | |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| |
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11011011 | |
01100001 | |
10001100 | |
11011111 | |
10001001 | |
11011101 | |
01001101 | |
00101111 | |
00001100 | |
01001101 | |
00010111 | |
00000110 | |
0100 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment