Js
Use JSP, read remote file, save to Local
Read the network file some different, I give you a complete code, stored as a JSP can be directly run.
<%@ page import= "java.io.*"%>
<%@ page import= "java.net.*"%>
<%@ page import= "Java.util.Properties"%>
<%
Process file path
String S1 = "http://www.google.co.jp";
Local Storage Path
String s2 = "c:\\test.html";
URL urlfile = null;
HttpURLConnection httpurl = null;
Bufferedinputstream bis = null;
Bufferedoutputstream BOS = NULL;
File F = new file (s2);
Make Proxy
String proxy = "192.168.224.12";
String port = "8080";
Properties systemproperties = System.getproperties ();
Systemproperties.setproperty ("Http.proxyhost", proxy);
Systemproperties.setproperty ("Http.proxyport", port);
try{
Pick up the designated Web?? SOURCE, net?? Inflow
Urlfile = new URL (S1);
Httpurl = (httpurlconnection) urlfile.openconnection ();
Httpurl.connect ();
bis = new Bufferedinputstream (Httpurl.getinputstream ());
}catch (Exception e) {
System.out.println (E.tostring ());
}
try{
BOS = new Bufferedoutputstream (new FileOutputStream (f));;
Byte[] B = new byte[1024];
while (Bis.read (b)!=-1) {
Bos.write (b);
}
}catch (Exception e) {
System.out.println (E.tostring ());
}finally{
try{
Bos.flush ();
Bis.close ();
Httpurl.disconnect ();
}catch (Exception e) {
System.out.println (E.tostring ());
}
}
%>
<center>
<form name= "Search" action= "results.jsp" method= "Get" >
<p>
<input name= "Query" size= "/> Search Criteria"
</p>
<p>
<input name= "Maxresults" size= "4" value= "M"/> Results per Page
<input type= "Submit" value= "Search"/>
</p>
</form>
</center>
which
Make Proxy
String proxy = "192.168.224.12";//Firewall address
String port = "8080"; Firewall port
Properties systemproperties = System.getproperties ();
Systemproperties.setproperty ("Http.proxyhost", proxy);
Systemproperties.setproperty ("Http.proxyport", port);
This section is if your machine set up a firewall, you need to add, if it is directly connected to the Internet, you do not need.