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{
//? Connect the specified network?? 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 the Criteria
</p>
<p>
<input name= "Maxresults" size= "4" value= "/>" results per page
<input type= "Submit" value= "Search"/>
</p>
</form>
</center>
where
//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 has a firewall set up, you need to add, if it is directly connected to the Internet, do not.