Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you can use x = y instead of x, y then you can use the Properties class.</p> <p>If you do need to have x, y then look at the <a href="http://java.sun.com/javase/6/docs/api/java/util/Scanner.html" rel="noreferrer">java.util.Scanner</a> you can set the delimiter to use as a separator (the javadoc shows examples of doing that).</p> <pre><code>import java.io.File; import java.io.FileNotFoundException; import java.util.Scanner; class Main { public static void main(final String[] argv) { final File file; file = new File(argv[0]); try { final Scanner scanner; scanner = new Scanner(file); while(scanner.hasNextLine()) { if(scanner.hasNext(".*,")) { String key; final String value; key = scanner.next(".*,").trim(); if(!(scanner.hasNext())) { // pick a better exception to throw throw new Error("Missing value for key: " + key); } key = key.substring(0, key.length() - 1); value = scanner.next(); System.out.println("key = " + key + " value = " + value); } } } catch(final FileNotFoundException ex) { ex.printStackTrace(); } } } </code></pre> <p>and the Properties version (way simpler for the parsing, as there is none)</p> <pre><code>import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.Reader; import java.util.Properties; class Main { public static void main(final String[] argv) { Reader reader; reader = null; try { final Properties properties; reader = new BufferedReader( new FileReader(argv[0])); properties = new Properties(); properties.load(reader); System.out.println(properties); } catch(final IOException ex) { ex.printStackTrace(); } finally { if(reader != null) { try { reader.close(); } catch(final IOException ex) { ex.printStackTrace(); } } } } } </code></pre>
    singulars
    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. 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