title: How can I provide an editable default value while reading STDIN with Java?
body: <p>. . I have a Java console app that is displaying a list of key=value properties to the user and indexes them so that they can type an index number, then edit the value, e.g.:</p>
  
  <pre><code>[0] foo=value 1
  [1] bar=value 2
  prompt&gt; edit 1
  bar=value 2
  new value?: *
  </code></pre>
  
  <p>(Asterisk is the prompt).  I'm collecting the input using what I think is the standard idiom for that:</p>
  
  <pre><code>BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
          input = bufferRead.readLine();
  </code></pre>
  
  <p>My problem is that I want to provide the existing value to the user after the prompt so that they can simple modify the value, e.g.:</p>
  
  <pre><code>[0] foo=value 1
  [1] bar=value 2
  prompt&gt; edit 1
  bar=value 2
  new value?: value 2*
  </code></pre>
  
  <p>How would I go about doing that?  It seems conceptually I would want to pre-load the input reader with the existing value but I'm not sure if that's the right thought or how I'd do that.  I saw a similar <a href="https://stackoverflow.com/questions/8021871/how-can-i-provide-an-editable-default-value-when-prompting-for-user-input">question</a> for perl but didn't run across anything for Java.  I have a feeling this is something that seems easy but isn't. . . ?</p>
  
  <p>Andy</p>