-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();
}
}
该文件正在使用错误的路径。 –