我在lines.txt文件夹下有一个文件Data。问题是,当我将lines.txt作为输入时,我会得到一个错误。错误发生在这一行SimpleReader inFile = new SimpleReader1L(inputFileName);
我知道这与道路有关,因为它没有得到认可,但我没有足够的经验去修复它。有人能告诉我我该怎么做吗?
import components.set.Set;
import components.simplereader.SimpleReader;
import components.simplereader.SimpleReader1L;
import components.simplewriter.SimpleWriter;
import components.simplewriter.SimpleWriter1L;
public final class pp {
public static void main(String[] args) {
SimpleReader in = new SimpleReader1L();
SimpleWriter out = new SimpleWriter1L();
/*
* Get input file name
*/
out.print("Input file (with fragments): ");
String inputFileName = in.nextLine();
SimpleReader inFile = new SimpleReader1L(inputFileName);
/*
* Get initial fragments from input file
*/
Set<String> fragments = linesFromInput(inFile);
/*
}
}我是simpleReader1L
public SimpleReader1L(String name) {
assert name != null : "Violation of: name is not null";
this.name = name;
try {
URL url = new URL(name);
this.rep =
new BufferedReader(new InputStreamReader(url.openStream()));
} catch (MalformedURLException e) {
// throw new AssertionError("Violation of: " + url + " is valid");
try {
this.rep = new BufferedReader(new FileReader(name));
} catch (FileNotFoundException ex) {
throw new AssertionError("Violation of: " + name + " exists");
}
} catch (FileNotFoundException e) {
throw new AssertionError("Violation of: " + name + " exists");
} catch (IOException e) {
throw new AssertionError("Violation of: " + name + " can be read");
}
}发布于 2021-07-17 01:12:17
错误发生在这一行SimpleReader inFile =newSimpleReader1L(InputFileName);
目前还不清楚SimpleReader1L期望的是什么输入。根据文件对象还是字符串作为fileName,您需要将实际对象或正确的路径作为字符串传递。
使用绝对路径(从根目录开始)。例如:
Windows:D:\somedir\lines.txt
Unix/Mac:/users/<username>/home/lines.txt
https://stackoverflow.com/questions/68416103
复制相似问题