Java String Index Of removeColumn(String line, int index)

Here you can find the source of removeColumn(String line, int index)

Description

remove Column

License

Open Source License

Declaration

static String removeColumn(String line, int index) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;
import java.util.Arrays;

public class Main {
    static String removeColumn(String line, int index) {

        ArrayList<String> splittingLine = new ArrayList<String>(
                Arrays.asList(line.split(",")));

        splittingLine.remove(index);/*from w ww . j a  v  a 2  s . c o  m*/

        return strArrayListToString(splittingLine);
    }

    static void removeColumn(ArrayList<String> lines, int index) {
        for (int i = 0; i < lines.size(); i++) {
            lines.set(i, removeColumn(lines.get(i), index));
        }
    }

    static String strArrayListToString(ArrayList<String> lstLine) {
        String line = "";

        for (int i = 0; i < lstLine.size(); i++) {
            line = line + lstLine.get(i);

            if (i != lstLine.size() - 1)
                line = line + ",";
        }

        return line;
    }
}

Related

  1. isPhaseGroupContainsPhase(int index, String phaseName)
  2. lastIndexOf(String pattern, String s)
  3. lastIndexOfIgnoreCase(final String s, final String subS)
  4. mergeStringLines(String lineOne, String lineTwo, int keyIndex, int insertingIndex)
  5. readColumn(int columnIndex, String inputString, String columnSeparator)
  6. splitUsingIndexOf(String splittee, String splitter)
  7. sub(String string, int fromIndex, int toIndex)
  8. subStringChinese(String str, int startIndex, int endIndex)