-2
我的程序是獲取具有CSV文件的URL。我試圖將它傳遞給一個文件進行進一步的查詢,但它返回一個NoSuchElementException。如何使用Java將CSV文件下載到文件中
public static void main(String[] args) throws ParseException, IOException, URISyntaxException {
// TODO Auto-generated method stub
String web = "https://example.com/data.csv";
URL content = new URL(web);
File file = new File(content.getPath());
try {
Scanner inputStream = new Scanner(file); //Input file
String[] values = data.split(",");
while (inputStream.hasNext()){
data = inputStream.next();
values = data.split(",");
System.out.println(values[];
}
inputStream.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
該文件正在使用錯誤的路徑。 –