package furniture;
import java.io.*;
import java.util.*;
public class Program3 {
public static void main(String[] args) {
//array of 10 Furniture object references
String[] furniture = new String[10];
String filename = "furnitureData.txt";
Scanner input = null;
try{
input = new Scanner(new File(filename));
}//end try
catch(FileNotFoundException e){
System.err.println(e);
System.exit(1);
}//end catch
}//end main
}
with this i can not figure out why it is throwing an error that says "java.io.FileNotFoundException: furnitureData.txt (The system cannot find the file specified)
Java Result: 1
BUILD SUCCESSFUL (total time: 3 seconds)"
I get it is saying it can't find the file and the name is spelt the exact same way. I pasted this file in like 5 different places, why is it still doing this? I am not asking for direct answers or gimmies, just guidance!
Below I cannot seem to figure out why my toString method return is not working. Im supposed to read a text file and store it into an array and then output it to how the toString method is. Again no gimmies, just guidance please!
package furniture;
import java.io.*;
import java.util.*;
public class Furniture extends Program3{
private double price;
private double length;
private double width;
public Furniture(){
this.price = 0.0;
this.length = 0.0;
this.width = 0.0;
}//end Furniture
public double getLength() {
return length;
}//end getLength
public void setLength(double length) {
this.length = length;
}//end setLength
public double getPrice() {
return price;
}//end getPrice
public void setPrice(double price) {
this.price = price;
}//end setPrice
public double getWidth() {
return width;
}//end getWidth
public void setWidth(double width) {
this.width = width;
}//end setWidth
@Override
public String toString(){
return "Furniture{price=" + getPrice() + ", length=" + getLength() ", width=" + getWidth() + "}";
}//end toString
public void display(PrintStream output){
}//end display
public void readStreamData(String[] furniture){
Scanner input = new Scanner("furnitureData.txt");
int count = 0;
while(input.hasNext()){
furniture[count] = input.nextLine();
count++;
}//end while loop
}//end readStreamData
}
this class is the same for the other two classes i have with the same toString method problem on the return, which only difference is the names changing which the other two are called Desk and Table.
Thank you for your help, guidance, and assistance!