Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>The simplest way to do this would be to read it using regular file paths.</p> <p>On Windows:</p> <pre><code>new File("\\\\server\\path\\to\\file.txt") // (double-backslashes required for backslashes in path) </code></pre> <p>On Unix:</p> <p>First mount the share using Samba (SMB, NFS or whatever other protocol) to some location like /mnt/network. Then you can use:</p> <pre><code>new File("/mnt/network/path/to/file.txt") </code></pre> <p>Once you have the File object you can use FileInputStream, FileReader or whatever else you want to read the file in.</p> <p><em>Edit</em> for comments response. If you are using an Applet, you probably want to pull the file from a web server. You can use the built in java.net.URL class but I would recommend this if you have to do more than just simple stuff: <a href="http://hc.apache.org/httpclient-3.x/index.html" rel="noreferrer">http://hc.apache.org/httpclient-3.x/index.html</a></p> <p>Example (from the Commons HTTP Site):</p> <pre><code> // Create an instance of HttpClient. HttpClient client = new HttpClient(); // Create a method instance. GetMethod method = new GetMethod(url); try { // Execute the method. int statusCode = client.executeMethod(method); if (statusCode != HttpStatus.SC_OK) { System.err.println("Method failed: " + method.getStatusLine()); } // Read the response body. byte[] responseBody = method.getResponseBody(); // Deal with the response. // Use caution: ensure correct character encoding and is not binary data System.out.println(new String(responseBody)); } catch (HttpException e) { System.err.println("Fatal protocol violation: " + e.getMessage()); e.printStackTrace(); } catch (IOException e) { System.err.println("Fatal transport error: " + e.getMessage()); e.printStackTrace(); } finally { // Release the connection. method.releaseConnection(); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload