Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>Guava Sample Usage</h2> <p>Yes, using Guava is a great idea, especially for simple tasks as <a href="http://docs.guava-libraries.googlecode.com/git/javadoc/com/google/common/io/Files.html#toString(java.io.File,%20java.nio.charset.Charset)" rel="noreferrer">reading a file</a>:</p> <pre><code>String contents = Files.toString(file, Charsets.UTF_8) </code></pre> <p>when compared to plain java versions like this:</p> <pre><code>BufferedReader in = null; StringBuilder sb = new StringBuilder(); try { in = new BufferedReader(new FileReader(file)); String str; while ((str = in.readLine()) != null) { sb.append(str).append('\n'); } } catch (IOException e) { // do something here } finally{ // and this should also be in a try / catch block if(in!=null)in.close(); } return sb.toString(); </code></pre> <p>(But actually you need to have developed Java for years to really appreciate the easiness IMHO.)</p> <h2>Configuring Eclipse to use Guava</h2> <p>The easiest way to deal with such a library in Eclipse is to create a User library and add the user library to your project (right click project: <code>Build Path -&gt; Add Library -&gt; User Library</code>).</p> <p>Here is a short guide to generating a User Library:</p> <ol> <li>Open the menu entry <code>Preferences -&gt; Java -&gt; Build Path -&gt; User Libraries</code></li> <li>Press <code>New...</code>, enter a name (e.g. 'Guava')</li> <li>Press <code>Add JARs...</code> and search for the JAR files you downloaded<br> (Unzip the <a href="http://guava-libraries.googlecode.com/files/guava-r07.zip" rel="noreferrer">Guava archive</a> beforehand, inside you'll find the file <code>guava-r07.jar</code>. Select that in this dialog, preferably after moving it to a more desirable location)</li> <li>Now select <code>Source Attachment -&gt; Edit...</code>, and find the path to the file <code>guava-src-r07</code>.</li> <li>If you want to, you can repeat this process for the JavaDoc location, pointing it to the <code>javadoc</code> folder from the guava distribution</li> <li>Press <code>OK</code>.</li> </ol> <p>Now you should be all set, you can select the user library and add it to a project of your choice.</p> <h2>Using Maven</h2> <p>For completeness: being an advocate of dependency management with maven I would of course suggest to manage project dependencies with <a href="http://maven.apache.org/" rel="noreferrer">maven</a> and <a href="http://m2eclipse.sonatype.org/" rel="noreferrer">m2eclipse</a> instead of with user libraries.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

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