Java Console/控制台 打印表格

功能:控制台打印表格,支持字段动态长度,左对齐,右对齐,居中,设置最大列长,设置列间隔符,设置最多打印多少行。

类下载地址:http://download.csdn.net/download/j506825719/10211082

简单使用方法:在new的时候,给定列名,和列值List,之后调用printTable就得到了表格字符串。

进阶使用方法:查看所有public方法,就能知道还有什么功能了。

效果图如下:


接口如下:

package com.benjamin.debug.extendclass;

import java.awt.Font;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 
 * @author Benjamin su
 * QQ:506825719
 * Email:jiang506825719@qq.com
 *
 */
public class TextTable {
	//这个变量只是用来获取字符串的标准长度,修改无意义
	private static Font font = new Font("宋体", Font.PLAIN, 16);
	private String columnInterval="|";//列之间的间隔符号
	private AlignType at=AlignType.Left;
	private Integer MaxValueLenth=40;
	private Map<String,Integer> maxFieldValueLengthMap=null;
	List<String> columnNameList=null;
	List<List<String>> columnValueList=null;
	private boolean isException=false;
	private Integer pringtTableRow=30;
	/**
	 * 初始化时不给定列长度Map
	 * @param columnNameListTmp
	 * @param columnValueListTmp
	 */
	public TextTable(List<String> columnNameListTmp,List<List<String>> columnValueListTmp){
	}
	/**
	 *  初始化时给定列长度Map
	 * @param columnNameListTmp
	 * @param columnValueListTmp
	 * @param maxFieldValueLengthMapTmp
	 */
	public TextTable(List<String> columnNameListTmp,List<List<String>> columnValueListTmp,Map<String,Integer> maxFieldValueLengthMapTmp){
	}
	
	/**
	 * 获得处理后的表格字符串
	 * @return
	 */
	public String printTable(){
	}
	/**
	 * 获取一个字符串的标准长度是多少
	 * A2*.  这样是四个标准长度
	 * 系统系统 这样是8个标准长度
	 * @param str
	 * @return
	 */
    public static Integer getStrPixelsLenth(String str){  
    }
    /**
     * 让列值居中
     * @param columnValue
     * @param ColumnPixelsLenth
     * @return
     */
    private String makeValueCenter(String columnValue,Integer repaireStrLength){
    }
    /**
     * 让列值左对齐
     * @param columnValue
     * @param ColumnPixelsLenth
     * @return
     */
    private String makeValueLeft(String columnValue,Integer repaireStrLength){
    }
    /**
     * 让列值右对齐
     * @param columnValue
     * @param ColumnPixelsLenth
     * @return
     */
    private String makeValueRight(String columnValue,Integer repaireStrLength){
    }
    /**
     * 获取用于填充的字符串
     * @param str
     * @param PixelsLenth
     * @return
     */
    private static String getRepairStr(char str,Integer PixelsLenth){
    }
    /**
     * 根据像素长度来切割字符串
     * @param str
     * @param PixelsLenth
     * @return
     */
    private static String subStrByPixels(String str,Integer PixelsLenth){
    }
    /**
     * 让列值对齐(左对齐OR居中OR右对齐)
     * @param columnValue
     * @param ColumnPixelsLenth
     * @return
     */
    private String makeValueAlign(String columnValue,Integer ColumnPixelsLenth){
    }
    /**
     * 设置列与列之间用什么间隔,默认是|
     * @param columnInterval
     */
	public void setColumnInterval(String columnInterval) {
	}
	/**
	 * 设置列值最大长度,超过则用省略号代替
	 * @param maxValueLenth
	 */
	public void setMaxValueLenth(Integer maxValueLenth) {
	}
	/**
	 * 如果不指定列长度Map,这里将自动计算
	 * @param columnNameListTmp
	 * @param columnValueListTmp
	 * @param maxFieldValueLengthMapTmp
	 */
	private void setMaxFieldValueLengthMap(List<String> columnNameListTmp,List<List<String>> columnValueListTmp,Map<String, Integer> maxFieldValueLengthMapTmp) {
	}
	/**
	 * 设置最多打印多少行
	 * @param pringtTableRow
	 */
	public void setPringtTableRow(Integer pringtTableRow) {
	}
	/**
	 * 设置对齐方式
	 * @param at
	 */
	public void setAt(AlignType at) {
	}
	public enum AlignType {
    	Left,
        Center,
        Rigth
    }
}



  • 1
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值