title: Shuffle middle characters of words in a string?
body: <p>Here is the question I need to solve:</p>
  
  <blockquote>
  <pre><code>I  dn’ot gvie a dman for a man taht can only sepll a word one way. 
  </code></pre>
    
    <p>Write a method String scramble(String word) that constructs a
    scrambled version of a given word, randomly flipping two characters
    other than the first and last one. Then write a program that reads
    words from a file “input.txt”  (one word per line) and outputs the
    each word with its scrambled version (one pair per line) to another
    file “scrambled.txt”.</p>
  </blockquote>
  
  <p>I don't need a string to be converted to words, just one word per line. I need to read words, not strings.</p>
  
  <p>So far, what I've done is this:</p>
  
  <pre><code>import java.util.*;
  import java.io.*;
  
  public class examhelp
  {
      public static void main(String[]args)throws IOException
      {
          Scanner kbd=new Scanner(System.in);
          File f=new File("words.txt");
          Scanner inputFile=new Scanner(f);
          PrintWriter outputFile=new PrintWriter("scrambled.txt");
          bloop wlist=new bloop();
          while(inputFile.hasNext())
          {
              String ww=inputFile.nextLine();
              System.out.println(ww);
              outputFile.println(wlist.scramble(ww));
          }
          inputFile.close();
          outputFile.close();
      }
  }
  
  class bloop
  {
      public static String scramble(String word)
      {
          String shuffledString = ""; 
  
          while (word.length() != 0)
          {
              int index = (int) Math.floor(Math.random() * word.length());
              char c = word.charAt(index);
              word = word.substring(0,index)+word.substring(index+1);
              shuffledString += c;
          }
  
          return shuffledString;
      }
  }
  </code></pre>
  
  <p>Now the problem is, it shuffles ALL the letters, including the first and last, and I cant' do that according to the question. Can you please help me with my method and what exact code should be there? I can take a look at it and see where I was wrong and what I needed to do. Thanks.</p>
  
  <p>I need to do it WITHOUT the arrays or any pre-defined methods. </p>