尝试使用url类和url.openstream()从url读取文件。
代码:
try {
URL url = new URL("http://www.puzzlers.org/pub/wordlists/pocket.txt");
Scanner s = new Scanner(url.openStream());
// read from your scanner
}
catch(IOException ex) {
// there was some connection problem, or the file did not exist on the server,
// or your URL was not in the right format.
// think about what to do now, and put it here.
ex.printStackTrace(); // for now, simply output it.
}
我得到一个错误:openstream iusundefined for the docflavor.url方法。
我尝试的是:
ide建议更改我所做的转换,结果是:
URL url = new URL("http://www.puzzlers.org/pub/wordlists/pocket.txt");
Scanner s = new Scanner(((Object) url).openStream());
// read from your scanner
仍然是相同的错误。我还尝试将对象更改为url:
URL url = new URL("http://www.puzzlers.org/pub/wordlists/pocket.txt");
Scanner s = new Scanner(((URL) url).openStream());
// read from your scanner
请帮忙谢谢!
1条答案
按热度按时间hm2xizp91#
补充
import java.net.URL
把其他的都拿走了.net and URL imports