I'm working on a program that calls for me to write a program that opens a binary file and prints all ASCII characters from that file, that is, all bytes with values between 32 and 126. Print a new line after every 64 characters.
Here is a sample program run:
Filename:
HelloPrinter.class
2ā€¯HelloPrinterjava/lang/Object<init>()VCodeLineNumberTableLocalV
ariableTablethisLHelloPrinter;main([Ljava/lang/String;)Vjava/lan
g/SystemoutLjava/io/PrintStream;Hello, World!java/io/PrintStream
println(Ljava/lang/String;)Vargs[Ljava/lang/String;SourceFileHel
loPrinter.java!/*7 !
Here is my code
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Scanner;
public class ASCIIPrinter
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.println("Filename: ");
String filename = in.next();
try
{
InputStream inStream = new FileInputStream(filename);
boolean done = false;
int counter = 0;
final int LINE_LENGTH = 64;
while (!done)
{
// Write code here
}
if (counter > 0)
System.out.println();
inStream.close();
}
catch(IOException e)
{
e.printStackTrace();
}
}
}