join JTable Column - Java Swing

Java examples for Swing:JTable Column

Description

join JTable Column

Demo Code


//package com.java2s;

import javax.swing.JTable;

public class Main {
    public static String joinTableColum(JTable table, int column) {
        StringBuffer sb = new StringBuffer();
        String s = null;/* w ww . j a  va 2 s  .c o m*/

        for (int i = 0; i < table.getRowCount(); i++) {
            s = (String) table.getValueAt(i, column);
            if (s == null) {
                s = "";
            }
            sb.append(s + ";");
        }
        if (sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }
}

Related Tutorials