<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 165, comments - 198, trackbacks - 0, articles - 1
      BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

    mysql 導出文本數據轉換展現格式

    Posted on 2008-07-25 16:39 G_G 閱讀(2159) 評論(0)  編輯  收藏 所屬分類: javaGeneral


    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?{
    ????
    // 數據文本?
    ???? static ?String?filePath? = ? " smsservice.data " ;
    ????
    // 輸出文本
    ???? static ?String?outfile? = ? " outfile.html " ;
    ????
    // 輸出?文本格式
    ???? static ?String?charset? = ? " GBK " ;

    ????
    // 數據邏輯?展現
    ???? 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 " ),? " 圖表 " );
    ??????? ......

    ????}

    ????
    // 禁止展現
    ???? 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);
    ????????
    ????????
    // ?內存?裝載?處
    ????????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);
    ????????????}
    ????????}
    ????????
    ????????
    // 列數據收集
    ???????? 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>長號碼</td> "
    ????????????????
    + ? " <td>資費</td> " ? + ? " <td>業務類型(圖表/客戶端)</td> " ? + ? " </tr>\n " );
    ????????
    // ?通道伙伴?指令?長號碼?資費?業務類型(圖表?客戶端?)
    ????????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();
    ????}

    }

    主站蜘蛛池模板: 最近免费中文字幕4| 91精品国产免费久久国语蜜臀| 成熟女人牲交片免费观看视频| 精品亚洲麻豆1区2区3区| 久久这里只精品热免费99| 亚洲AV无码成人精品区蜜桃| 男人都懂www深夜免费网站| 精品久久久久久亚洲| 少妇性饥渴无码A区免费 | 亚洲av无码国产综合专区| 黄页网站在线观看免费高清| 亚洲a级片在线观看| 免费观看黄网站在线播放| 亚洲精华国产精华精华液好用| 免费一看一级毛片| 国产精品hd免费观看| 久久综合日韩亚洲精品色| **实干一级毛片aa免费| 在线观看亚洲AV日韩A∨| 国产成人高清精品免费软件| 男男gay做爽爽的视频免费| 久久亚洲色一区二区三区| 国产午夜成人免费看片无遮挡 | 久久WWW免费人成人片| 白白色免费在线视频| 亚洲成av人在线视| 1024免费福利永久观看网站| 亚洲av无码一区二区三区天堂| 亚洲精品无码久久久| 久久狠狠躁免费观看2020| 亚洲乱码中文字幕在线| 久久亚洲中文字幕精品一区四| 亚洲精品在线免费观看视频| 亚洲狠狠婷婷综合久久| 亚洲成AV人片在线观看| AV免费网址在线观看| 久草免费福利在线| 亚洲偷自精品三十六区| 亚洲无码日韩精品第一页| 国内精自视频品线六区免费| 黄网站色成年片大免费高清|