我正在嘗試開發巡航控制系統的Java應用程序。但是我沒有這樣的文件異常問題。因爲我在java編碼方面有點新。我不知道爲什麼會出現這個問題。我的代碼是 -Java顯示錯誤NoSuchFileException
public static void main(String[] commandLineArgs) throws IOException {
Path input_path = Paths.get(commandLineArgs[0]);
List<InputState> input_states = StateInput.input_states_from_file(input_path);
Timer timer = new Timer(new CruiseControlSystem());
List<OutputState> output_states = timer.pulse_from_input(input_states);
for (OutputState s : output_states){
System.out.println(s.format());
}
}
而且我發現的錯誤是 -
Exception in thread "main" java.nio.file.NoSuchFileException: commandLineArgs[0]
at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
at java.nio.file.Files.newByteChannel(Unknown Source)
at java.nio.file.Files.newByteChannel(Unknown Source)
at java.nio.file.spi.FileSystemProvider.newInputStream(Unknown Source)
at java.nio.file.Files.newInputStream(Unknown Source)
at java.nio.file.Files.newBufferedReader(Unknown Source)
at java.nio.file.Files.readAllLines(Unknown Source)
at StateInput.input_states_from_file(StateInput.java:31)
at CommandLine.main(CommandLine.java:23)
我的主要方法是 -
public static void main(String[] commandLineArgs) throws IOException {
Path input_path = Paths.get(commandLineArgs[0]);
List<InputState> input_states = StateInput.input_states_from_file(input_path);
Timer timer = new Timer(new CruiseControlSystem());
List<OutputState> output_states = timer.pulse_from_input(input_states);
for (OutputState s : output_states){
System.out.println(s.format());
}
}
@kushagra_mittal我hav修改了我的問題,並給出了主要方法 – ktina51
你使用eclipse或命令行來運行這個嗎? –
我試圖用eclipse運行這個 – ktina51