title: replace random number of characters at random position with wildcard
body: <p>I am trying to create a program which would replace random number of characters at random position with "*". Star is letter used in main program and it is replaced with "." a wildcard to matches any possible result.</p>
  
  <p>So far I manage to create the code you see bellow. It replaces exactly 1 character of specific word.
  Any help from here on now would be much appreciated.</p>
  
  <p><strong>EXAMPLE:</strong></p>
  
  <p>Input word: MOUSE</p>
  
  <p>RANDOM GENERATOR for how much characters to replace: 3</p>
  
  <p>RANDOM GENERATOR at which places to replace: 1, 3, 5</p>
  
  <p>RESULT: *O*S* </p>
  
  <pre><code>public class random_2 {
  
  public static void main(String[] args) {
      String test;
      int dolzina = 0;
      String outputFile = "random_2.txt";
      ArrayList&lt;String&gt; list = new ArrayList();
  
      try {
  
          File file = new File("random1.txt");
          FileReader fileReader = new FileReader(file);
          BufferedReader bufferedReader = new BufferedReader(fileReader);
          String vrstica;
          while ((vrstica = bufferedReader.readLine()) != null) {
  
              list.add(vrstica);
              // dolzina=list.size();
              // System.out.println(dolzina);
  
          }
  
          FileWriter fileWriter = new FileWriter(outputFile);
          PrintWriter out = new PrintWriter(fileWriter);
          for (int idx = 0; idx &lt;= list.size(); ++idx) {
              test=list.get(idx);
              dolzina=test.length();
  
              Random rGenerator = new Random();
  
              for (int i = 0; i&lt;= dolzina; ++i) {
                  int randomInt = rGenerator.nextInt(dolzina);
                  StringBuilder beseda = new StringBuilder(test);
                  beseda.setCharAt(randomInt, '*');
                  System.out.println(beseda);
                  dolzina=0;
          }}
  
          System.out.println("Done.");
  
      } catch (IOException e) {
          e.printStackTrace();
  
      }
  }
  }
  </code></pre>