先生からの簡単な割り当てのカットアンドペーストであるはずのこのコードを実行しようとしています。ただし、指示に従った後でも、次のエラーメッセージが表示されます。
指定されたファイルShapeData.txtが見つかりませんでした。
これは30行目を参照しています。
ファイルを切り取って他のすべてのフォルダーと同じフォルダーに貼り付けたので、なぜまだエラーが発生するのかわかりません。コマンドラインで何かをすることについても読みましたが、それが何をするのかわかりません。
(ああ、これは宿題や私が成績のために提出できるものではありません。それは私たちがよりよく理解するために見ることができるものです。)
これが私のコード、または少なくとも最初の数行です。
/**
* Concepts demonstrated:
* Object Inheritance
* Interfaces
* Interface Implementation
* Reading Data from a File
* Sorting an Array
* Manipulating Strings
*/
import java.util.Scanner;
/**
* This lab demonstrates the basics of object-oriented programming.
*/
public class Lab8 {
private static Shape[] shapes; // An array to hold all the shape objects
public static void main(String[] args) {
DataReader reader = new DataReader("ShapeData.txt");// The reader is used to read data from a file
// Display program information
System.out.println("Ima Java Programmer");
System.out.println("Shape Info");
// Load data from the file
if(reader.loadData("ShapeData.txt")) { // The filename is entered using a command-line argument
shapes = reader.getShapeData(); // Store the arrays in the array
// Display how many shapes were read from the file
System.out.println("Successfully loaded " + shapes[0].getCount() +
" shapes from the selected data file!");
displayMenu();
}
}