I want to read particular string from a text file and store them in Excel sheets

前端 未结 4 878
遇见更好的自我
遇见更好的自我 2021-01-24 04:02

My Text file Contains line like this

FLTR TID: 0000003756 RPC ID: 0000108159 USER: Remedy Application Service

FLTR TID: 0000003756 RPC ID: 0

4条回答
  •  青春惊慌失措
    2021-01-24 04:39

    • For Unique Names you can Use ArrayList add whenever new UserName appears add and before that check whether user exist in arrayList or not (by the Use of contains("UName")) and than proceed.
    • Use String username=line.substring(line.lastindexOf(":")).trim(); or You can use line.split(":")[1].trim();

    For Excel row creation you can use loop.

    int i=0;
    while((str=br.readLine())!=null){
    row = sheet.createRow((short) i);
    cell = row.createCell(i);
    cell.setCellValue("UserName");//Set UserName after getting it from 'str'
    i++;
    }
    

提交回复
热议问题