Creates a new File instance by converting the given file: URI into an abstract pathname. The exact form of a file: URI is system-dependent, hence the transformation performed by this constructor is also system-dependent. For a given abstract pathname f it is guaranteed that new File( f.toURI()).equals( f.getAbsoluteFile()) so long as the original abstract pathname, the URI, and the new abstract pathname are all created in (possibly different invocations of) the same Java virtual machine. This relationship typically does not hold, however, when a file: URI that is created in a virtual machine on one operating system is converted into an abstract pathname in a virtual machine on a different operating system.
你的a.doc应该写相对路径才对吧
The exact form of a file: URI is system-dependent, hence the transformation performed by this constructor is also system-dependent. For a given abstract pathname f it is guaranteed that new File( f.toURI()).equals( f.getAbsoluteFile())
so long as the original abstract pathname, the URI, and the new abstract pathname are all created in (possibly different invocations of) the same Java virtual machine. This relationship typically does not hold, however, when a file: URI that is created in a virtual machine on one operating system is converted into an abstract pathname in a virtual machine on a different operating system.
try {
input = new URL("http://www.socs.uts.edu.au/MosaicDocs-old/url-primer.html ").openStream();
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
BufferedReader in2 = new BufferedReader(new InputStreamReader(input));
try {
in2.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}这个试试!网上找了找!好像你那种是不行
按字面意识应该是uri应该以“file”开头
用你的方法抛出异常: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
有高手指点一下吗?