`
CoderDream
  • 浏览: 477458 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

CSI Bug修改记录

阅读更多

需求:

在表A:S2s中有3个字段,cust_id,form_date和isTransmit,在表B:Flag中,有3个字段:cust_id、startDate和endDate,请找出S2s中的某些记录,约束条件如下:

1、该笔记录的cust_id存在于表Flag中,即S2s.cust_id=Flag.cust_id;

2、该笔记录的isTransmit值为N;

3、该笔记录的form_date在表Flag的startDate和endDate之间,即form_date>=startDate且form_date<=endDate;

4、form_date格式为YYYYMMDD,startDate和endDate格式为YYYY-MM-DD;

 

由于Production环境的资料需要保密,只能提供表A的3个自动和表B的3字段,现在客户已经导出到txt文档,每笔记录包含3个字段,以空格分开。

 

下面我们分步骤开实现如何测试客户提供的数据:

1、创建2个类,将文本文件中的数据实例化对象;

public class S2s {

    private String cust_id;
    private String form_date;
    private String isTransmit;

    /**
     * @return the cust_id
     */
    public String getCust_id() {
        return cust_id;
    }

    /**
     * @param cust_id the cust_id to set
     */
    public void setCust_id(String cust_id) {
        this.cust_id = cust_id;
    }

    /**
     * @return the form_date
     */
    public String getForm_date() {
        return form_date;
    }

    /**
     * @param form_date the form_date to set
     */
    public void setForm_date(String form_date) {
        this.form_date = form_date;
    }

    /**
     * @return the isTransmit
     */
    public String getIsTransmit() {
        return isTransmit;
    }

    /**
     * @param isTransmit the isTransmit to set
     */
    public void setIsTransmit(String isTransmit) {
        this.isTransmit = isTransmit;
    }

}
 
public class Flag {
    private String customer_id;
    private String startDate;
    private String endDate;

    /**
     * @return the customer_id
     */
    public String getCustomer_id() {
        return customer_id;
    }

    /**
     * @param customer_id the customer_id to set
     */
    public void setCustomer_id(String customer_id) {
        this.customer_id = customer_id;
    }

    /**
     * @return the startDate
     */
    public String getStartDate() {
        return startDate;
    }

    /**
     * @param startDate the startDate to set
     */
    public void setStartDate(String startDate) {
        this.startDate = startDate;
    }

    /**
     * @return the endDate
     */
    public String getEndDate() {
        return endDate;
    }

    /**
     * @param endDate the endDate to set
     */
    public void setEndDate(String endDate) {
        this.endDate = endDate;
    }

}
 

 

2、分行读取文本文件,并将每条记录序列化为对象,存储到List中:

我们先来看看txt文档中的片段:

S223821747       2008-09-05 2008-09-15
A227577478       2008-09-05 2008-09-15
L123462919       2008-09-05 2008-09-15
S124039554       2008-09-05 2008-09-15
F224800911       2008-09-05 2008-09-15
A225667273       2008-09-05 2008-09-15
F223968423       2008-09-05 2008-09-15
Z100098584       2008-09-05 2008-09-30
H122644620       2008-09-05 2008-09-30
U221392263       2008-09-05 2008-09-30
A227669499       2008-09-05 2008-09-30
N224708641       2008-09-05 2008-09-30
B290023255       2008-09-05 2008-09-30
C221114157       2008-09-05 2008-09-30
T220902657       2008-09-05 2008-09-30

 从中我们可以看到,3个字段以空格分隔,其中第一个字段和第二个字段中间有多个空格;

    FileReader reader = new FileReader(flagFileName);
    BufferedReader br = new BufferedReader(reader);
    String s1 = null;
    while ((s1 = br.readLine()) != null) {
         //TODO
    }

 3、将得到的字符串分割为字符数组(String[]):

s2 = s1.split(" ");

 4、通过打印字符数组可知s2[0]、s2[6]、s2[7]为3个字段的位置,将3个字段的值放入对象并存储到List中:

f = new Flag();
f.setCustomer_id(s2[0]);
f.setStartDate(s2[7]);
f.setEndDate(s2[8]);
flagList.add(f);

 该方法的完整代码如下:

     /**
     * 从Flag 的txt文件中按行读取,将得到的3个字符串分别放入Flag对象中,
     * 然后将对于存储在返回List中
     * @return
     */
    public static List readFlag() {
        FileReader reader = null;
        List flagList = new ArrayList();
        try {
            reader = new FileReader(flagFileName);

            BufferedReader br = new BufferedReader(reader);
            String s1 = null;
            String[] s2 = null;
            Flag f = null;
            int i = 0;
            int j = 0;
            while ((s1 = br.readLine()) != null) {
                s2 = s1.split(" ");
                //               
                if (s2.length != 9) {
                    f = new Flag();
                    f.setCustomer_id(s2[0]);
                    f.setStartDate(s2[6]);
                    f.setEndDate(s2[7]);
                    i++;
                    j++;
                    flagList.add(f);
                    continue;
                }

                f = new Flag();
                f.setCustomer_id(s2[0]);
                f.setStartDate(s2[7]);
                f.setEndDate(s2[8]);
                i++;
                flagList.add(f);
            }

            br.close();
            reader.close();
        }
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return flagList;
    }

 5、判断时间区间,由于时间格式不同,先要去掉startDate和endDate的“-”,用String的replaceAll()即可,然后就可以直接比较了:

    /**
     * 先将Flag对象中的startDate和endDate的格式由YYYY-MM-DD转换为YYYYMMDD
     * 然后看S2s对象中的formDate是否:
     *    formDate.compareTo(startDate) >= 0)
     *          && (formDate.compareTo(endDate) <= 0
     * 比对结果为返回值
     * @param s
     * @param f
     * @return
     */
    public static boolean inDateField(S2s s, Flag f) {

        String formDate = s.getForm_date();
        if (f == null) {
            return false;
        }

        String startDate = f.getStartDate();
        String endDate = f.getEndDate();

        if (formDate == null || "".equals(formDate) || startDate == null
                || "".equals(startDate) || endDate == null
                || "".equals(endDate)) {
            return false;
        }

        startDate = startDate.replaceAll("-", "");
        endDate = endDate.replaceAll("-", "");

        return (formDate.compareTo(startDate) >= 0)
                && (formDate.compareTo(endDate) <= 0);
    }

 6、最后我们来看S2s中的cust_id是否存在于表Flag中,我们先读取Flag中的所有记录,然后将所有cust_id存于一个HashSet中,同时以cust_id为Key,以Flag对象为Value,存储到一个HashMap中;然后使用HashSet的contains()看cust_id是否存在于此HashSet中:

custIdSet.contains(s.getCust_id()

 完整代码如下:

    public static void compareId() {
        List s2sList = getListS2sN(readS2s());
        List flagList = readFlag();
        Flag f = null;
        // 存放“新開戶ID清單”中的ID
        Set custIdSet = new HashSet();
        Map beansMap = new HashMap();
        int refSize2 = 0;
        if (flagList != null && flagList.size() > 0) {
            refSize2 = flagList.size();
        }
        for (int i = 0; i < refSize2; i++) {
            f = (Flag) flagList.get(i);
            custIdSet.add(f.getCustomer_id());
            beansMap.put(f.getCustomer_id(), f);
        }

        System.out.println("custIdSet.size(): " + custIdSet.size());
        System.out.println("beansMap.size(): " + beansMap.size());

        int refSize = 0;
        if (s2sList != null && s2sList.size() > 0) {
            refSize = s2sList.size();
        }
        System.out.println("s2sList.size(): " + refSize);
        S2s s = null;
        for (int i = 0; i < refSize; i++) {
            s = (S2s) s2sList.get(i);
            f = (Flag) beansMap.get(s.getCust_id());
            System.out.println(custIdSet.contains(s.getCust_id()) + " : "
                    + inDateField(s, f) + " : " + s.getCust_id() + ":");
            if (custIdSet.contains(s.getCust_id()) && inDateField(s, f)) {
                System.out.println("####" + i + ":"
                        + custIdSet.contains(s.getCust_id()) + " : "
                        + inDateField(s, f) + " : " + s.getCust_id() + ":");
            }
        }
    }
 

7、其他:

可以使用POI生成Excel档,代码如下:

    /**
     * 将S2s的List生成Excel档
     */
    public static void createExcelS2s() {
        String xlsFile = "D:/0Excel/S2s.xls";

        List s2sList = getListS2sN(readS2s());
        try {
            // 产生工作簿对象
            HSSFWorkbook workbook = new HSSFWorkbook();
            // 产生工作表对象,设置工作表的名称为Sheet1
            HSSFSheet sheet = workbook.createSheet("Sheet1");

            sheet.setColumnWidth((short) 0, (short) 4000);
            sheet.setColumnWidth((short) 1, (short) 2000);
            sheet.setColumnWidth((short) 2, (short) 3000);

            // 产生一行
            HSSFRow row = sheet.createRow((short) 0);
            // 产生第1个单元格 客戶ID或卡號 
            HSSFCell cell_01 = row.createCell((short) 0,
                    HSSFCell.CELL_TYPE_STRING);
            cell_01.setCellValue(new HSSFRichTextString("cust_id"));
            // 产生第2个单元格 BLK
            HSSFCell cell_02 = row.createCell((short) 1,
                    HSSFCell.CELL_TYPE_STRING);
            cell_02.setCellValue(new HSSFRichTextString("form_date"));
            // 产生第3个单元格 處理時間
            HSSFCell cell_03 = row.createCell((short) 2,
                    HSSFCell.CELL_TYPE_STRING);
            cell_03.setCellValue(new HSSFRichTextString("isTransmit"));

            HSSFCell newCell_01 = null;
            HSSFCell newCell_02 = null;
            HSSFCell newCell_03 = null;
            int s2sSize = 0;
            if (s2sList != null) {
                s2sSize = s2sList.size();
            }
            S2s s = null;
            for (int i = 1; i < s2sSize; i++) {
                s = (S2s) s2sList.get(i);
                // 产生一行
                HSSFRow rowNew = sheet.createRow((short) i);
                newCell_01 = rowNew.createCell((short) 0,
                        HSSFCell.CELL_TYPE_STRING);
                newCell_01.setCellValue(new HSSFRichTextString(s.getCust_id()));
                // 产生第2个单元格 BLK
                newCell_02 = rowNew.createCell((short) 1,
                        HSSFCell.CELL_TYPE_STRING);
                newCell_02
                        .setCellValue(new HSSFRichTextString(s.getForm_date()));
                // 产生第3个单元格 處理時間
                newCell_03 = rowNew.createCell((short) 2,
                        HSSFCell.CELL_TYPE_STRING);
                newCell_03.setCellValue(new HSSFRichTextString(s
                        .getIsTransmit()));
            }

            FileOutputStream fOut = new FileOutputStream(xlsFile);
            workbook.write(fOut);
            fOut.flush();
            fOut.close();
            System.out.println("文件生成...");

            // 以下语句读取生成的Excel文件内容
            FileInputStream fIn = new FileInputStream(xlsFile);
            HSSFWorkbook readWorkBook = new HSSFWorkbook(fIn);
            HSSFSheet readSheet = readWorkBook.getSheet("Sheet1");
            HSSFRow readRow = readSheet.getRow(0);
            HSSFCell readCell = readRow.getCell((short) 0);
            System.out.println("第一個單元是:" + readCell.getRichStringCellValue());
        }
        catch (Exception e) {
            e.printStackTrace();
            System.out.println(e);
        }
    }
 

整个测试类的完整代码如下:

package com.coderdream.s2s;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;


public class Test {

    /** S2S_txt文件位置 */
    private static String s2sFileName = "S2S_1.txt";

    /** Flag_txt文件位置 */
    private static String flagFileName = "Flag_1.txt";

    /**
     * @param args
     */
    public static void main(String[] args) {
        //readS2s();

        //printListS2s(readS2s());
        //printListS2s(getListS2sN(readS2s()));
        //printListFlag(readFlag());
        //compareId();
        //testSet();
        //createExcel();
        //createExcelFlag();
        compareId();
        //testReplaceAll();
    }


    /**
     * 从S2s 的txt文件中按行读取,将得到的3个字符串分别放入S2s对象中,
     * 然后将对于存储在返回List中
     * 
     * @return
     */
    public static List readS2s() {
        FileReader reader = null;
        List s2sList = new ArrayList();
        try {
            reader = new FileReader(s2sFileName);

            BufferedReader br = new BufferedReader(reader);
            String s1 = null;
            String[] s2 = null;
            S2s s = null;
            while ((s1 = br.readLine()) != null) {
                // 根据导出的文本可知,字符串以空格分开
                s2 = s1.split(" ");
                s = new S2s();
                s.setCust_id(s2[0]);
                s.setForm_date(s2[7]);
                s.setIsTransmit(s2[9]);
                s2sList.add(s);
            }

            br.close();
            reader.close();
        }
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return s2sList;
    }

    /**
     * 从Flag 的txt文件中按行读取,将得到的3个字符串分别放入Flag对象中,
     * 然后将对于存储在返回List中
     * @return
     */
    public static List readFlag() {
        FileReader reader = null;
        List flagList = new ArrayList();
        try {
            reader = new FileReader(flagFileName);

            BufferedReader br = new BufferedReader(reader);
            String s1 = null;
            String[] s2 = null;
            Flag f = null;
            int i = 0;
            int j = 0;
            while ((s1 = br.readLine()) != null) {
                s2 = s1.split(" ");
                //               
                if (s2.length != 9) {
                    f = new Flag();
                    f.setCustomer_id(s2[0]);
                    f.setStartDate(s2[6]);
                    f.setEndDate(s2[7]);
                    i++;
                    j++;
                    flagList.add(f);
                    continue;
                }

                f = new Flag();
                f.setCustomer_id(s2[0]);
                f.setStartDate(s2[7]);
                f.setEndDate(s2[8]);
                i++;
                flagList.add(f);
            }

            br.close();
            reader.close();
        }
        catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return flagList;
    }

    /**
     * @param s2
     */
    public static void printArray(String[] s2) {
        for (int i = 0; i < s2.length; i++) {
            if (s2[i] != null && !"".equals(s2[i].trim())) {
                System.out.print(s2[i] + ":");

            }
        }
        System.out.println();
    }

    /**
     * @param s2sList
     */
    public static void printListS2s(List s2sList) {
        S2s s = null;
        int size = 0;
        if (s2sList != null) {
            size = s2sList.size();
        }
        int index = 0;
        for (int i = 0; i < size; i++) {
            s = (S2s) s2sList.get(i);
            index = i + 1;
            System.out.println(index + "\t:" + s.getCust_id() + ":"
                    + s.getForm_date() + ":" + s.getIsTransmit());
        }
    }

    /**
     * @param s2s
     */
    public static void printS2s(S2s s2s) {
        if (s2s != null) {
            System.out.println(s2s.getCust_id() + ":" + s2s.getForm_date()
                    + ":" + s2s.getIsTransmit());
        }
    }

    /**
     * @param s2sList
     * @return
     */
    public static List getListS2sN(List s2sList) {
        List list = new ArrayList();
        S2s s = null;
        int size = 0;
        if (s2sList != null) {
            size = s2sList.size();
        }

        for (int i = 0; i < size; i++) {
            s = (S2s) s2sList.get(i);
            if ("N".equals(s.getIsTransmit())) {
                list.add(s);
            }
        }

        return list;
    }

    /**
     * @param flagList
     */
    public static void printListFlag(List flagList) {
        Flag f = null;
        int size = 0;

        if (flagList != null) {
            size = flagList.size();
        }
        int index = 0;
        for (int i = 0; i < size; i++) {
            f = (Flag) flagList.get(i);
            index = i + 1;
            System.out.println(index + "\t:" + f.getCustomer_id() + ":"
                    + f.getStartDate() + ":" + f.getEndDate());
        }
    }

    /**
     * @param flag
     */
    public static void printFlag(Flag flag) {
        if (flag != null) {
            System.out.println(flag.getCustomer_id() + ":"
                    + flag.getStartDate() + ":" + flag.getEndDate());
        }
    }

    /**
     * 先将Flag对象中的startDate和endDate的格式由YYYY-MM-DD转换为YYYYMMDD
     * 然后看S2s对象中的formDate是否:
     *    formDate.compareTo(startDate) >= 0)
     *          && (formDate.compareTo(endDate) <= 0
     * 比对结果为返回值
     * @param s
     * @param f
     * @return
     */
    public static boolean inDateField(S2s s, Flag f) {

        String formDate = s.getForm_date();
        if (f == null) {
            return false;
        }

        String startDate = f.getStartDate();
        String endDate = f.getEndDate();

        if (formDate == null || "".equals(formDate) || startDate == null
                || "".equals(startDate) || endDate == null
                || "".equals(endDate)) {
            return false;
        }

        startDate = startDate.replaceAll("-", "");
        endDate = endDate.replaceAll("-", "");

        return (formDate.compareTo(startDate) >= 0)
                && (formDate.compareTo(endDate) <= 0);
    }


    /**
     * 
     */
    public static void compareId() {
        List s2sList = getListS2sN(readS2s());
        List flagList = readFlag();
        Flag f = null;
        // 存放“新開戶ID清單”中的ID
        Set custIdSet = new HashSet();
        Map beansMap = new HashMap();
        int refSize2 = 0;
        if (flagList != null && flagList.size() > 0) {
            refSize2 = flagList.size();
        }
        for (int i = 0; i < refSize2; i++) {
            f = (Flag) flagList.get(i);
            custIdSet.add(f.getCustomer_id());
            beansMap.put(f.getCustomer_id(), f);
        }

        System.out.println("custIdSet.size(): " + custIdSet.size());
        System.out.println("beansMap.size(): " + beansMap.size());

        int refSize = 0;
        if (s2sList != null && s2sList.size() > 0) {
            refSize = s2sList.size();
        }
        System.out.println("s2sList.size(): " + refSize);
        S2s s = null;
        for (int i = 0; i < refSize; i++) {
            s = (S2s) s2sList.get(i);
            f = (Flag) beansMap.get(s.getCust_id());
            System.out.println(custIdSet.contains(s.getCust_id()) + " : "
                    + inDateField(s, f) + " : " + s.getCust_id() + ":");
            if (custIdSet.contains(s.getCust_id()) && inDateField(s, f)) {
                System.out.println("####" + i + ":"
                        + custIdSet.contains(s.getCust_id()) + " : "
                        + inDateField(s, f) + " : " + s.getCust_id() + ":");
            }
        }
    }

    /**
     * 将S2s的List生成Excel档
     */
    public static void createExcelS2s() {
        String xlsFile = "D:/0Excel/S2s.xls";

        List s2sList = getListS2sN(readS2s());
        try {
            // 产生工作簿对象
            HSSFWorkbook workbook = new HSSFWorkbook();
            // 产生工作表对象,设置工作表的名称为Sheet1
            HSSFSheet sheet = workbook.createSheet("Sheet1");

            sheet.setColumnWidth((short) 0, (short) 4000);
            sheet.setColumnWidth((short) 1, (short) 2000);
            sheet.setColumnWidth((short) 2, (short) 3000);

            // 产生一行
            HSSFRow row = sheet.createRow((short) 0);
            // 产生第1个单元格 客戶ID或卡號 
            HSSFCell cell_01 = row.createCell((short) 0,
                    HSSFCell.CELL_TYPE_STRING);
            cell_01.setCellValue(new HSSFRichTextString("cust_id"));
            // 产生第2个单元格 BLK
            HSSFCell cell_02 = row.createCell((short) 1,
                    HSSFCell.CELL_TYPE_STRING);
            cell_02.setCellValue(new HSSFRichTextString("form_date"));
            // 产生第3个单元格 處理時間
            HSSFCell cell_03 = row.createCell((short) 2,
                    HSSFCell.CELL_TYPE_STRING);
            cell_03.setCellValue(new HSSFRichTextString("isTransmit"));

            HSSFCell newCell_01 = null;
            HSSFCell newCell_02 = null;
            HSSFCell newCell_03 = null;
            int s2sSize = 0;
            if (s2sList != null) {
                s2sSize = s2sList.size();
            }
            S2s s = null;
            for (int i = 1; i < s2sSize; i++) {
                s = (S2s) s2sList.get(i);
                // 产生一行
                HSSFRow rowNew = sheet.createRow((short) i);
                newCell_01 = rowNew.createCell((short) 0,
                        HSSFCell.CELL_TYPE_STRING);
                newCell_01.setCellValue(new HSSFRichTextString(s.getCust_id()));
                // 产生第2个单元格 BLK
                newCell_02 = rowNew.createCell((short) 1,
                        HSSFCell.CELL_TYPE_STRING);
                newCell_02
                        .setCellValue(new HSSFRichTextString(s.getForm_date()));
                // 产生第3个单元格 處理時間
                newCell_03 = rowNew.createCell((short) 2,
                        HSSFCell.CELL_TYPE_STRING);
                newCell_03.setCellValue(new HSSFRichTextString(s
                        .getIsTransmit()));
            }

            FileOutputStream fOut = new FileOutputStream(xlsFile);
            workbook.write(fOut);
            fOut.flush();
            fOut.close();
            System.out.println("文件生成...");

            // 以下语句读取生成的Excel文件内容
            FileInputStream fIn = new FileInputStream(xlsFile);
            HSSFWorkbook readWorkBook = new HSSFWorkbook(fIn);
            HSSFSheet readSheet = readWorkBook.getSheet("Sheet1");
            HSSFRow readRow = readSheet.getRow(0);
            HSSFCell readCell = readRow.getCell((short) 0);
            System.out.println("第一個單元是:" + readCell.getRichStringCellValue());
        }
        catch (Exception e) {
            e.printStackTrace();
            System.out.println(e);
        }
    }

    public static void createExcelFlag() {
        String xlsFile = "D:/0Excel/Flag.xls";

        List flagList = readFlag();
        try {
            // 产生工作簿对象
            HSSFWorkbook workbook = new HSSFWorkbook();
            // 产生工作表对象,设置工作表的名称为Sheet1
            HSSFSheet sheet = workbook.createSheet("Sheet1");

            sheet.setColumnWidth((short) 0, (short) 4000);
            sheet.setColumnWidth((short) 1, (short) 6000);
            sheet.setColumnWidth((short) 2, (short) 6000);


            // 产生一行
            HSSFRow row = sheet.createRow((short) 0);
            // 产生第1个单元格 cust_id
            HSSFCell cell_01 = row.createCell((short) 0,
                    HSSFCell.CELL_TYPE_STRING);
            cell_01.setCellValue(new HSSFRichTextString("cust_id"));
            // 产生第2个单元格 startDate
            HSSFCell cell_02 = row.createCell((short) 1,
                    HSSFCell.CELL_TYPE_STRING);
            cell_02.setCellValue(new HSSFRichTextString("startDate"));
            // 产生第3个单元格 endDate
            HSSFCell cell_03 = row.createCell((short) 2,
                    HSSFCell.CELL_TYPE_STRING);
            cell_03.setCellValue(new HSSFRichTextString("endDate"));

            HSSFCell newCell_01 = null;
            HSSFCell newCell_02 = null;
            HSSFCell newCell_03 = null;
            int flagSize = 0;
            if (flagList != null) {
                flagSize = flagList.size();
            }
            Flag f = null;
            for (int i = 1; i < flagSize; i++) {
                f = (Flag) flagList.get(i);
                // 产生一行
                HSSFRow rowNew = sheet.createRow((short) i);
                // 产生第1个单元格 cust_id
                newCell_01 = rowNew.createCell((short) 0,
                        HSSFCell.CELL_TYPE_STRING);
                newCell_01.setCellValue(new HSSFRichTextString(f
                        .getCustomer_id()));
                // 产生第2个单元格 startDate
                newCell_02 = rowNew.createCell((short) 1,
                        HSSFCell.CELL_TYPE_STRING);
                newCell_02
                        .setCellValue(new HSSFRichTextString(f.getStartDate()));
                // 产生第3个单元格 endDate
                newCell_03 = rowNew.createCell((short) 2,
                        HSSFCell.CELL_TYPE_STRING);
                newCell_03.setCellValue(new HSSFRichTextString(f.getEndDate()));
            }

            FileOutputStream fOut = new FileOutputStream(xlsFile);
            workbook.write(fOut);
            fOut.flush();
            fOut.close();
            System.out.println("文件生成...");

            // 以下语句读取生成的Excel文件内容
            FileInputStream fIn = new FileInputStream(xlsFile);
            HSSFWorkbook readWorkBook = new HSSFWorkbook(fIn);
            HSSFSheet readSheet = readWorkBook.getSheet("Sheet1");
            HSSFRow readRow = readSheet.getRow(0);
            HSSFCell readCell = readRow.getCell((short) 0);
            System.out.println("第一個單元是:" + readCell.getRichStringCellValue());
        }
        catch (Exception e) {
            System.out.println(e);
        }
    }

    public static void testReplaceAll() {
        String startDate = "2008.09.01";
        String endDate = "2008.09.30";
        String sDate = startDate.replaceAll("[.]", "");
        String eDate = endDate.replaceAll("[.]", "");
        System.out.println(startDate + ":" + endDate + ":" + sDate + ":"
                + eDate);
    }

}
 

运行结果:

custIdSet.size(): 20
beansMap.size(): 20
s2sList.size(): 10
true : false : S223821747:
true : false : L123462919:
false : false : F223700449:
false : false : U120222840:
true : false : F224800911:
true : false : S223821747:
true : true : Z100098584:
####6:true : true : Z100098584:
false : false : L100867210:
true : true : C221114157:
####8:true : true : C221114157:
true : true : B122081672:
####9:true : true : B122081672:
 
  • S2sDemo.rar (11.2 KB)
  • 描述: 直接通过eclipse导入工具,然后添加POI包
  • 下载次数: 2
分享到:
评论

相关推荐

    室内CSI指纹定位数据集参考

    通过修改NIC的设备驱动程序,来读取每个数据包接收时以CSI的形式记录在硬件中的CSI值,并生成包含CSI信息的dat文件。这些dat文件是以二进制进行保存的,最后我们还要使用MATLAB或者Python程序来读取dat文件,从而...

    shiyan_0823_shyan_afei_处理csi数据_csi_csi预处理_CSI特征提取matlab_wificsi_

    这篇关于“处理csi数据_csi_csi预处理_CSI特征提取matlab_wificsi”的研究主要关注如何利用商用WiFi设备和MATLAB来处理和分析 CSI 数据,特别是在识别用户行为(如走、坐和蹲)方面的应用。 首先,我们来理解一下 ...

    libsvm-3.18.rar_CSI 定位_CSI信道状态_CSI定位_CSI室内_室内信道

    采集信道状态信息CSI的功能代码,csi包括幅度相位等更细粒度的信道信息,用于室内定位的最新选择

    mipi 系列资源(CSI2、CSI3、D-PHY等)

    mipi_CSI-2_specification_v2-1-er01-2018.pdf mipi_CSI-3_specification_v1-0.pdf MIPI_Alliance_Specification_for_Camera_Serial_Interface_2__CSI_2_2009.pdf MIPI_D-PHY_Specification_v01-00-00.pdf ...

    已知和未知CSI时的信道容量比较_csi_信道容量_

    MIMO系统利用空间多样性和信道的状态信息(CSI)来实现性能优化。本文将详细探讨在已知和未知信道状态信息情况下的信道容量比较。 一、信道状态信息(CSI) 信道状态信息是描述信号从发射端到接收端传播过程中受到...

    linux-80211n-csitool-supplementary.zip_CSITool_CSI信道状态_csi数据预处理_

    标题中的“linux-80211n-csitool-supplementary.zip”是一个压缩包文件,主要涉及的内容是“CSITool”,它是一个用于处理802.11n无线网络中“CSI(Channel State Information)”信道状态信息的工具。这个工具在...

    CSI Tool 监控模式下双向CSI采集(同时发送并接收数据).zip

    "CSI Tool 监控模式下双向CSI采集(同时发送并接收数据)"是一个专注于无线通信中信道状态信息(Channel State Information, CSI)采集的项目。这个项目的目标是实现设备在监控模式下能够同时进行发送和接收数据,...

    Atheros-CSI-Tool-User-Guide(OpenWrt).pdf

    3. **监控CSI数据**:利用Atheros-CSI-Tool或其他工具来监控并记录收集到的CSI数据。 #### 五、总结 通过本文的详细介绍,我们可以了解到在OpenWrt上安装Atheros-CSI-Tool所需的一系列步骤和技术要点。从确认系统...

    CSI_Denoise_csi_CSI反馈去噪网络论文_

    《基于深度学习的CSI反馈去噪网络在FDD大规模MIMO系统中的应用》 这篇论文是东南大学金老师近期的研究成果,聚焦于通信系统中一个关键的问题——信道状态信息(Channel State Information, 简称CSI)的反馈去噪。在...

    collect_data_CSI数据提取_csi信号处理_csi_grabbedo7y_

    这可能需要对接基站或终端设备的软件接口,如使用特定的API或者SDK,实时获取并记录信道测量报告。这个过程可能需要对通信协议有深入的理解,例如在LTE或5G系统中,如何解析和解码信道质量指示符(CQI)以及其他相关...

    mipi_CSI-3 英文原版官方文档

    MIPI CSI-3,全称为Mobile Industry Processor Interface Camera Serial Interface 3,是MIPI Alliance推出的一种高速、低功耗的接口标准,用于连接图像传感器和应用处理器。在摄像头开发领域,MIPI CSI-3被广泛应用...

    获取CSI matlab绘图

    在MATLAB中,"CSI"通常指的是Channel State Information,即信道状态信息,这在无线通信领域是非常重要的概念。当你需要获取并绘制CSI时,这通常涉及到信号处理、频谱分析以及通信系统的建模。本篇文章将深入探讨...

    cpp-CSITool监控模式下双向CSI采集同时发送并接收数据

    在IT领域,尤其是在无线通信和网络优化中,Channel State Information (CSI) 是一个关键的参数,它描述了无线信道的特性。这篇文章将深入探讨如何在C++编程环境下,使用名为"CSITool"的工具在监控模式下实现双向CSI...

    CSITool工具包

    CSITool工具包是一款专为测量和分析信道状态信息(Channel State Information, 简称CSI)设计的专业工具。在无线通信领域,尤其是移动通信系统中, CSI 是至关重要的参数,它反映了无线信号在传播过程中受到的各种...

    mipi_CSI-2_specification_v1_mipi_CSI2资料_mipicsi2_mipi_MIPIcsi_mi

    MIPI(Mobile Industry Processor Interface)CSI-2(Camera Serial Interface - 2)是一种高速、低功耗的接口标准,主要用于连接图像传感器与处理器之间。在移动设备和物联网领域,MIPI CSI-2已经成为图像和视频...

    Convolutional_LTSM_CSI_estimate_stateestimate_wireless_csi_LTSM_

    标题中的"Convolutional_LTSM_CSI_estimate_stateestimate_wireless_csi_LTSM_"提到了几个关键概念:卷积 LSTM(ConvLSTM)、状态估计(state estimate)、无线信道状态信息(wireless Channel State Information, ...

    CSI-2协议标准pdf

    在提供的压缩包中,包含的是“MIPI Alliance Specification for Camera Serial Interface - 2 (CSI-2)”的PDF文档,这是一份详细阐述MIPI CSI-2协议标准的技术规范。 MIPI CSI-2协议是MIPI联盟为高清摄像头和图像...

    Parallel to MIPI CSI-2 TX Bridge

    ### 平行至MIPI CSI-2 TX桥接器知识点详解 #### 一、MIPI CSI-2标准介绍 MIPI(Mobile Industry Processor Interface)是由移动行业处理器接口联盟提出的一系列标准规范,主要应用于智能手机、平板电脑等消费电子...

    NR CSI-RS.pptx

    NR CSI-RS序列生成;NR CSI-RS-RE映射; NR CSI-RS周期与偏移; NR CSI-RS空间域;CSI参考信号分为non-zero-power CSI-RS 、Zero-power CSI-RS两类: non-zero-power CSI-RS 在其占用的RE 上发送真正的CSI-RS,即在...

Global site tag (gtag.js) - Google Analytics