Use JSP, read remote files, save to local

xiaoxiao2021-03-19  207

Use JSP, read remote files, save to local

Reading the network file is somewhat different, I will give you a complete code, you can run directly into JSP. <% @ page import = "java.io. *"%> <% @ Page Import = "java.net. *"%> <% @ page import = "java.util.properties"%> <%

/ / The file 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 proxyString proxy = "192.168.224.12"; String port = "8080"; Properties systemProperties = System.getProperties (); systemProperties.setProperty ( "http.proxyHost", proxy); systemProperties.setProperty ( "http.proxyPort" , Port);

Try {//? Adjun to the network ?? Source,? Take the network ?? Entering urlfile = new url (S1); httpurl = (httpurlconnection) URLFILE.OpenConnection (); httpurl.connect (); bis = new bufferedInputStream (httpurl .GetinputStream ());} catch (exception e) {system.out.println (e.tostring ());}

转载请注明原文地址:https://www.9cbs.com/read-130048.html

New Post(0)