java未知协议:下载文件时为e
我是java文件处理的初学者。我厌倦了从硬盘分区到web应用程序中获取一个bin文件(en parser chunking.bin)。到目前为止,我已经尝试了下面的代码,它在下面的控制台中为我提供了输出 未知协议:e 这些是我迄今为止尝试过的代码示例java未知协议:下载文件时为e,java,file,url,download,Java,File,Url,Download,我是java文件处理的初学者。我厌倦了从硬盘分区到web应用程序中获取一个bin文件(en parser chunking.bin)。到目前为止,我已经尝试了下面的代码,它在下面的控制台中为我提供了输出 未知协议:e 这些是我迄今为止尝试过的代码示例 //download file public void download(String url, File destination) throws IOException { URL website = new URL(url);
//download file
public void download(String url, File destination) throws IOException {
URL website = new URL(url);
ReadableByteChannel rbc = Channels.newChannel(website.openStream());
FileOutputStream fos = new FileOutputStream(destination);
fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
}
public void parserAction() throws Exception {
//InputStream is = new FileInputStream("en-parser-chunking.bin");
File modelFile = new File("en-parser-chunking.bin");
if (!modelFile.exists()) {
System.out.println("Downloading model.");
download("E:\\Final Project\\Softwares and tools\\en-parser-chunking.bin", modelFile);
}
ParserModel model = new ParserModel(modelFile);
Parser parser = ParserFactory.create(model);
Parse topParses[] = ParserTool.parseLine(line, parser, 1);
for (Parse p : topParses){
//p.show();
getNounPhrases(p);
}
}
以这种方式获取文件是可能的,还是我做错了
注意-我需要从我的硬盘上得到这个。不从internet下载本地文件的正确URL为:
file://E:/Final Project/Softwares and tools/en-parser-chunking.bin
其中文件
是协议
您还可以:
new File("E:/Final Project/Softwares and tools/en-parser-chunking.bin").toURL()
从文件创建URL
我还建议使用斜杠作为文件分隔符,而不是反斜杠。本地文件的正确URL为:
file://E:/Final Project/Softwares and tools/en-parser-chunking.bin
其中文件
是协议
您还可以:
new File("E:/Final Project/Softwares and tools/en-parser-chunking.bin").toURL()
从文件创建URL
我还建议使用斜杠作为文件分隔符,而不是反斜杠这会给我下面的输出“下载模型。连接超时:连接”这会给我下面的输出“下载模型。连接超时:连接”