title: Java String Manipulation into Columns
body: <p>I'm working on a tool and am required to split text into columns.</p>
  
  <p>For example - 1 2 3 4 5 6 7 8 9 1</p>
  
  <p>Would return this if the period is 2 - 
  1,3,5,7,9
  and 
  2,4,6,8,1</p>
  
  <p>IF the period is 3 - 
  1,4,7,1 and
  2,5,8 and
  3,6,9</p>
  
  <p>Etc etc. 
  I'm struggling to construct this alogirithm, any help would be appreciated!  How is best to go about constructing these sort of algorithms? I've written it down on paper but can't transfer into code! I'm stuck on constructing a second loop to increase the period. Here's an example of what I have so far</p>
  
  <pre><code>    String to_test = "1234567891";
      StringBuilder sb = new StringBuilder();
  
      int period = 2;
      int startAt = 0;
      int characterToCheck = 0; 
  
      while (startAt &lt; period) {
          for (int i = 0; i &lt; to_test.length(); i++) {
              if (i % period == 0) {
                  sb.append(to_test.charAt(characterToCheck));
              }
              characterToCheck++;
          }
          // String is constructed
          System.out.println(sb);
          sb = new StringBuilder();
          startAt ++;
          characterToCheck = startAt; 
      }
  
  }
  </code></pre>