fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. import java.io.IOException;
  9. import java.util.ArrayList;
  10. import java.util.List;
  11.  
  12. class A {
  13. private List<String> nonParsedData;
  14. private List<String[]> parsedData;
  15.  
  16. public static void main(String[] args) throws Exception {
  17. A a = new A();
  18. // init
  19. a.nonParsedData = new ArrayList<>();
  20. a.parsedData = new ArrayList<>();
  21.  
  22. // fill non parsed
  23. a.nonParsedData.add("abcdefghijklmno");
  24. a.nonParsedData.add("123456789012345");
  25. a.nonParsedData.add("AZERTYUIOPQSDFG");
  26.  
  27. a.parseData();
  28. a.fetchAndPrint();
  29. }
  30.  
  31. public void parseData() throws IOException
  32. {
  33. //for reference, nonParsedData is ArrayList<String>
  34. // while parsedData is ArrayList<String[]>
  35. String line;
  36.  
  37. for (int x = 0; x < nonParsedData.size(); x++)
  38. {
  39. String[] tempContainer = new String[7];
  40. line = nonParsedData.get(x);
  41.  
  42. //filling the temporary container to place into the ArrayList of arrays
  43. tempContainer[0] = line.substring(0,1); //Data piece 1
  44. tempContainer[1] = line.substring(1,3); //Data piece 2
  45. tempContainer[2] = line.substring(3,7); //Data piece 3
  46. tempContainer[3] = line.substring(7,8); //Data piece 4
  47. tempContainer[4] = line.substring(8,9); //Data piece 5
  48. tempContainer[5] = line.substring(9,10); //Data piece 6
  49. tempContainer[6] = line.substring(10,(line.length() - 1)); //Data piece 7
  50.  
  51.  
  52.  
  53. parsedData.add(tempContainer);
  54. }
  55. }
  56.  
  57. public void fetchAndPrint() throws IOException
  58. {
  59. String[] tempContainer;
  60.  
  61. for(int x = 0; x < parsedData.size(); x++)
  62. {
  63.  
  64. tempContainer = parsedData.get(x); //this should be assigning my stored array to
  65. //the tempContainer array (I think)
  66.  
  67. //let's try deepToString (that didn't work)
  68. //System.out.println((parsedData.get(x)).toString()); //just a debugging check
  69.  
  70. System.out.println(x);
  71. System.out.println(tempContainer[0] + " " + tempContainer[1] + " "
  72. + tempContainer[2] + " " + tempContainer[3] + " "
  73. + tempContainer[4] + " " + tempContainer[5] + " "
  74. + tempContainer[6] + " ");
  75. }
  76. }
  77. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
0
a bc defg h i j klmn 
1
1 23 4567 8 9 0 1234 
2
A ZE RTYU I O P QSDF