Here's a simple example:
Expand|Select|Wrap|Line Numbers
- Input ArrayList would be:
- ArrayList<String> temp = new ArrayList<String>(2);
- temp.add("headerTest\\headerSectionTest\\");
- temp.add("headerTest\\start-time\\sameLastPartTest");
- temp.add("headerTest\\end-time\\sameLastPartTest");
- temp.add("DataTest\\TimeTest\\");
- temp.add("DataTest\\PieceOfDataTest\\");
- The String[][] that I want would be (assuming my code works):
- String[][] splittedStrings = new splittedStrings[temp.size()][];
- splittedStrings[0] = { "headerTest", "headerSectionTest" };
- splittedStrings[1] = { "headerTest", "start-time", "sameLastPartTest" };
- splittedStrings[2] = { "headerTest", "end-time", "sameLastPartTest" };
- splittedStrings[3] = { "DataTest", "TimeTest" };
- splittedStrings[4] = { "DataTest", "PieceOfDataTest" };
Expand|Select|Wrap|Line Numbers
- public static void main(String args[]) {
- ArrayList<String> temp = new ArrayList<String>(2);
- temp.add("headerTest\\headerSectionTest\\");
- temp.add("headerTest\\start-time\\sameLastPartTest");
- temp.add("headerTest\\end-time\\sameLastPartTest");
- temp.add("DataTest\\TimeTest\\");
- temp.add("DataTest\\PieceOfDataTest\\");
- runTCW rTCW = new runTCW(temp);
- rTCW.start();
- try {
- rTCW.join();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
Expand|Select|Wrap|Line Numbers
- public MyTableModel(ArrayList<String> al) {
- numRows = al.size();
- data = new Object[numRows][numCols];
- String[][] tagsSeparated = new String[numRows][];
- for (int i = 0; i < numRows; i++) {
- tagsSeparated[i] = al.get(i).split("\\"); //This is where the error is reported, where I use the .split("\\") method
- }
- for (int i = 0; i < numRows; i++) {
- data[i][0] = new Boolean(true);
- data[i][1] = al.get(i);
- data[i][2] = al.get(i);
- Utilities.print(tagsSeparated[i]);
- data[i][3] = al.get(i);
- }
- }
Expand|Select|Wrap|Line Numbers
- Exception in thread "main" java.util.regex.PatternSyntaxException: Unexpected internal error near index 1
- \
- ^
- at java.util.regex.Pattern.error(Pattern.java:1700)
- at java.util.regex.Pattern.compile(Pattern.java:1453)
- at java.util.regex.Pattern.<init>(Pattern.java:1130)
- at java.util.regex.Pattern.compile(Pattern.java:822)
- at java.lang.String.split(String.java:2293)
- at java.lang.String.split(String.java:2335)
- at TagChoosingWindow$MyTableModel.<init>(TagChoosingWindow.java:210)
- at TagChoosingWindow.<init>(TagChoosingWindow.java:39)
- at runTCW.<init>(runTCW.java:14)
- at TagChoosingWindow.main(TagChoosingWindow.java:157)
- Process completed.
-blazed