How do I convert rows as columns while reading from a file?
<p>How can I read and convert file stream below</p>

<p>0101011110<br/>
0000011010<br/>
0000001011<br/>
1000011000<br/></p>

<p>write as below;</p>

<p>0001<br/>
1000<br/>
0000<br/>
1000<br/>
0000<br/>
1101<br/>
1111<br/>
1000<br/>
1110<br/>
0010<br/></p>

<p>ArrayList does not sustain my requirements, it collapsed after a few trials.<br/>
I have 100k rows and 40 columns within my file. After reading line by line as strings, I do not know what to do as a newbie I tried this:</p>

<pre><code> ArrayList&lt;String&gt; list=new ArrayList&lt;String&gt;();
        String sequence;
        while((sequence= instream.readLine())!= null) {
            list.add(sequence);  
        }
        Iterator&lt;String&gt; it=list.iterator();
        for(int i=0; i&lt;40; i++){
        while(it.hasNext()){
            String temp=  it.next();
            outstream.write(temp.charAt(i)+" ");    
        }
        outstream.newLine();
      }
</code></pre>

<hr>

<p>This does the work!</p>

<pre><code>List&lt;String&gt; list = new ArrayList&lt;String&gt;();
        String sequence;

        while ((sequence = instream.readLine()) != null)
            list.add(sequence);

        for (int i = 0; i &lt; 40; i++) {
            for (String item : list) {
                outstream.write(item.charAt(i) + " ");
            }
            outstream.newLine();
        }
</code></pre>
