import java.util.Scanner; import java.io.*; public class Binary1 implements Seri
ID: 3545843 • Letter: I
Question
import java.util.Scanner;
import java.io.*;
public class Binary1 implements Serializable
{
public static void main (String [] args) throws IOException
{
boolean dofile = true;
boolean dofile1 = true;
String yn = "n", fname = "", bt = "b", rw = "r", line = "", readBinary = "";
PrintWriter textOut = null;
Scanner inputStream = null;
ObjectInputStream inputBinary = null;
ObjectOutputStream outputBinary = null;
OutputText mto = null;
OutputBinary mbo = null;
ObjectOutputStream binaryOut = null;
StringBuffer contents = new StringBuffer();
Scanner keyboard = new Scanner(System.in);
do{
System.out.println("Enter the file name.");
fname = keyboard.nextLine();
System.out.println("Chose binary or text file (b/t):");
bt = keyboard.nextLine();
if(bt.equalsIgnoreCase("b")){
mbo = new OutputBinary(fname);
binaryOut = mbo.createBinaryFile();
System.out.println("Chose read or write (r/w):");
rw = keyboard.nextLine();
if (rw.equalsIgnoreCase("r")){
try{
inputBinary = new ObjectInputStream(new FileInputStream(fname + ".dat"));
readBinary = inputBinary.readUTF();
System.out.println("File contains..." + readBinary);
inputBinary.close();
}
catch (IOException e){
System.out.println("The file is blank, please write in it.");
}
}
else if(rw.equalsIgnoreCase("w")){
do{
System.out.println("Enter a line of information to write to the file:");
try{
line = keyboard.nextLine();
binaryOut.writeUTF(line);
binaryOut.flush();
binaryOut.close();
}
catch(IOException e){
System.out.println("Problem with file output.");
}
System.out.println("Would you like to enter another line? (y/n)");
yn = keyboard.nextLine();
if(yn.equalsIgnoreCase("n"))
dofile1 = false;
}while(dofile1);
}
}
else if(bt.equalsIgnoreCase("t")){
mto = new OutputText(fname);
textOut = mto.createTextFile();
System.out.println("Chose read or write (r/w):");
rw = keyboard.nextLine();
if(rw.equalsIgnoreCase("r")){
try {
inputStream = new Scanner(new FileInputStream(textOut+".txt"));
String textLine = null;
while((textLine = inputStream.nextLine()) != null){
contents.append(textLine)
.append(System.getProperty("line.separator"));
}
}
catch (FileNotFoundException e) {
System.out.println("Cannot find file.");
}finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
System.out.println(contents.toString());
inputStream.close();
}
else if(rw.equalsIgnoreCase("w")){
do{
System.out.println("Enter a line of information to write to the file:");
line = keyboard.nextLine();
try{
textOut = mto.createTextFile();
}
catch(Exception e){
System.out.println(e);
}
textOut.println(line);
textOut.flush();
textOut.close();
System.out.println("Would you like to enter another line? (y/n)");
yn = keyboard.nextLine();
if(yn.equalsIgnoreCase("n"))
dofile1 = false;
}while(dofile1);
}
}else
System.out.println("What kind of bizzare choice is " + bt);
System.out.println("Would you like to do another file? (y/n)");
yn = keyboard.nextLine();
if(yn.equalsIgnoreCase("n"))
dofile = false;
}while(dofile);
}
}
is the error it throws back at me
----jGRASP exec: javac -g Binary1.java
Binary1.java:19: error: cannot find symbol
OutputText mto = null;
^
symbol: class OutputText
location: class Binary1
Binary1.java:20: error: cannot find symbol
OutputBinary mbo = null;
^
symbol: class OutputBinary
location: class Binary1
Binary1.java:39: error: cannot find symbol
mbo = new OutputBinary(fname);
^
symbol: class OutputBinary
location: class Binary1
Binary1.java:87: error: cannot find symbol
mto = new OutputText(fname);
^
symbol: class OutputText
location: class Binary1
4 errors
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
Explanation / Answer
Need the Assignment Document
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.