posts - 165, comments - 198, trackbacks - 0, articles - 1
            BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理


          package ?uu;

          import ?java.io.BufferedReader;
          import ?java.io.File;
          import ?java.io.FileInputStream;
          import ?java.io.FileOutputStream;
          import ?java.io.InputStreamReader;
          import ?java.io.OutputStreamWriter;
          import ?java.util.ArrayList;
          import ?java.util.HashMap;
          import ?java.util.List;
          import ?java.util.Map;
          import ?java.util.regex.Pattern;

          public ? class ?MainExc?{
          ????
          // 數(shù)據(jù)文本?
          ???? static ?String?filePath? = ? " smsservice.data " ;
          ????
          // 輸出文本
          ???? static ?String?outfile? = ? " outfile.html " ;
          ????
          // 輸出?文本格式
          ???? static ?String?charset? = ? " GBK " ;

          ????
          // 數(shù)據(jù)邏輯?展現(xiàn)
          ???? static ?Map < Pattern,?String > ?map? = ? new ?HashMap < Pattern,?String > ();
          ????
          static ?{
          ????????map.put(Pattern.compile(
          " ^XZT " ),? " sina " );
          ??????? 。。。。。
          ????}

          ????
          // 類型定義
          ???? static ?Map < Pattern,?String > ?maptype? = ? new ?HashMap < Pattern,?String > ();
          ????
          static ?{
          ????????maptype.put(Pattern.compile(
          " ^3P45 " ),? " 客戶端 " );
          ????????maptype.put(Pattern.compile(
          " ^6930 " ),? " 圖表 " );
          ??????? ......

          ????}

          ????
          // 禁止展現(xiàn)
          ???? static ?List < Pattern > ?listNo? = ? new ?ArrayList < Pattern > ();
          ????
          static ?{
          ????????listNo.add(Pattern.compile(
          " ^9588Command$ " ));
          ????????listNo.add(Pattern.compile(
          " ^5kjsCommand$ " ));
          ????????listNo.add(Pattern.compile(
          " ^529901001011021$ " ));
          ????????listNo.add(Pattern.compile(
          " ^529901001011022$ " ));
          ????}

          ????
          ????
          ????
          public ? static ? void ?main(String[]?args)? throws ?Exception?{
          ????????
          // ?read
          ????????InputStreamReader?read? = ? new ?InputStreamReader(
          ????????????????
          new ?FileInputStream(MainExc. class .getClassLoader().getResource(
          ????????????????????????filePath).getPath()),?charset);
          ????????
          ????????
          // ?writer
          ???????? if ?(MainExc. class .getClassLoader().getResource(outfile)? == ? null )?{
          ????????????
          new ?File(MainExc. class .getClassLoader().getResource( " . " ).getPath()
          ????????????????????
          + ? " /outfile.html " ).createNewFile();
          ????????}
          ????????OutputStreamWriter?writer?
          = ? new ?OutputStreamWriter(
          ????????????????
          new ?FileOutputStream(MainExc. class .getClassLoader()
          ????????????????????????.getResource(outfile).getPath()),?charset);
          ????????
          ????????
          // ?內(nèi)存?裝載?處
          ????????List < Map < String,?String >> ?datas? = ? new ?ArrayList < Map < String,?String >> ();

          ????????
          ????????
          ????????StringBuffer?buffer?
          = ? new ?StringBuffer();
          ????????BufferedReader?reader?
          = ? new ?BufferedReader(read);
          ????????String?stmp?
          = ? null ;
          ????????List
          < String > ?colName? = ? new ?ArrayList < String > ();
          ????????
          // 得到?列名
          ???????? if ?((stmp? = ?reader.readLine())? != ? null ? && ? ! stmp.trim().equals( "" ))?{
          ????????????
          // ?split?-?>?Tab
          ???????????? for ?(String?stmp2?:?stmp.split( " ???? " ))?{
          ????????????????colName.add(stmp2);
          ????????????}
          ????????}
          ????????
          ????????
          // 列數(shù)據(jù)收集
          ???????? while ?((stmp? = ?reader.readLine())? != ? null ? && ? ! stmp.trim().equals( "" ))?{

          ????????????Map
          < String,?String > ?data? = ? new ?HashMap < String,?String > ();
          ????????????String[]?sdata?
          = ?stmp.split( " ???? " );
          ????????????
          for ?( int ?i? = ? 0 ;?i? < ?colName.size();?i ++ )?{
          ????????????????data.put(colName.get(i),?sdata[i]);
          ????????????}
          ????????????datas.add(data);
          ????????}

          ????????
          ????????
          // ?writer
          ????????writer.append( " <center><table??border>\n " );
          ????????writer.append(
          " <tr> " ? + ? " <td>通道伙伴</td> " ? + ? " <td>指令</td> " ? + ? " <td>長(zhǎng)號(hào)碼</td> "
          ????????????????
          + ? " <td>資費(fèi)</td> " ? + ? " <td>業(yè)務(wù)類型(圖表/客戶端)</td> " ? + ? " </tr>\n " );
          ????????
          // ?通道伙伴?指令?長(zhǎng)號(hào)碼?資費(fèi)?業(yè)務(wù)類型(圖表?客戶端?)
          ????????wfor:? for ?(Map < String,?String > ?mtmp?:?datas)?{

          ????????????
          for ?(Pattern?ptmp?:?listNo)?{
          ????????????????
          if ?(ptmp.matcher(mtmp.get( " command " )).find())?{
          ????????????????????
          continue ?wfor;
          ????????????????}
          ????????????}

          ????????????String?hzhb?
          = ? "" ;

          ????????????
          for ?(Pattern?ptmp?:?map.keySet())?{
          ????????????????
          if ?(ptmp.matcher(mtmp.get( " command " )).find())?{
          ????????????????????hzhb?
          = ?map.get(ptmp);
          ????????????????}
          ????????????}

          ????????????String?type?
          = ? "" ;
          ????????????
          for ?(Pattern?ptmp?:?maptype.keySet())?{
          ????????????????
          if ?(ptmp.matcher(mtmp.get( " command " )).find())?{
          ????????????????????type?
          = ?maptype.get(ptmp);
          ????????????????}
          ????????????}

          ????????????writer.append(
          " <tr> " ? + ? " <td?align='center'> " ? + ?hzhb? + ? " </td> "
          ????????????????????
          + ? " <td?align='center'> " ? + ?mtmp.get( " command " )? + ? " </td> "
          ????????????????????
          + ? " <td?align='center'> " ? + ?mtmp.get( " num " )? + ? " </td> "
          ????????????????????
          + ? " <td?align='center'> " ? + ?mtmp.get( " money " )? + ? " </td> "
          ????????????????????
          + ? " <td?align='center'> " ? + ?type? + ? " </td> " ? + ? " </tr>\n " );
          ????????}
          ????????writer.append(
          " </table></center>\n " );

          ????????
          // ?save?
          ????????writer.flush();
          ????????writer.close();
          ????}

          }

          主站蜘蛛池模板: 合江县| 侯马市| 时尚| 平遥县| 梅河口市| 名山县| 宝鸡市| 洛隆县| 浙江省| 项城市| 栾川县| 平江县| 扶沟县| 泰兴市| 沽源县| 河西区| 五家渠市| 太仆寺旗| 五常市| 江陵县| 秦皇岛市| 辰溪县| 阿合奇县| 封开县| 永寿县| 财经| 延吉市| 和田市| 祁门县| 新源县| 藁城市| 奉贤区| 宁都县| 攀枝花市| 盐城市| 龙南县| 东至县| 佳木斯市| 监利县| 建湖县| 巩留县|