0 Replies - 282 Views - Last Post: 04 October 2012 - 12:16 PM Rate Topic: -----

#1 It's A Trap!  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 04-October 12

Javascript, Binary and text files reader compile error

Posted 04 October 2012 - 12:16 PM

I'm getting these compile errors

Binary.java:15: error: cannot find symbol
OutputText mto = null;
^
symbol: class OutputText
location: class Binary
Binary.java:16: error: cannot find symbol
OutputBinary mbo = null;
^
symbol: class OutputBinary
location: class Binary
Binary.java:32: error: cannot find symbol
mbo = new OutputBinary(fname);
^
symbol: class OutputBinary
location: class Binary
Binary.java:80: error: cannot find symbol
mto = new OutputText(fname);
^
symbol: class OutputText
location: class Binary
4 errors



import java.io.*;
import java.util.Scanner;

public class Binary implements Serializable{

public static void main(String[] args) {

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.sepa…
}
}

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.toSt…
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);

}





I know that OutputText and OutputBinary are the problems, can anyone post the code that I need to change it to? That would be a great help.


Is This A Good Question/Topic? 0
  • +

Replies To: Javascript, Binary and text files reader compile error

#2 fromTheSprawl  Icon User is offline

  • Monomania
  • member icon

Reputation: 513
  • View blog
  • Posts: 2,056
  • Joined: 28-December 10

Re: Javascript, Binary and text files reader compile error

Posted 05 October 2012 - 02:01 AM

You need to import those classes.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1