想飛就別怕摔

          大爺?shù)牟M罵人

          以HTTP形式獲取圖片流并寫入另一個(gè)圖片。

          圖片流操作:
                          //conn.getInputStream()獲取url所訪問圖片的InputStream字節(jié)流
                          
          //formatName是圖片的擴(kuò)展名如:“jpg/gif”等
                          
          //Constant.PATH為新圖片的地址
                          
          //pictureName新圖片的名稱
                          String smsUrl = "http://" + resConfig.getCommonShowAddress()+"/" + sms.getSmsUrl();
                          URL url 
          = null;
                          URLConnection conn 
          = null;
                          url 
          = new URL(smsUrl);
                          conn 
          = url.openConnection();
                          BufferedImage image 
          = ImageIO.read(conn.getInputStream());
                          String formatName 
          = filePostfix.substring(1, filePostfix.length());
                          ImageIO.write(image, formatName, 
          new File(Constant.PATH, pictureName));

          如果不是圖片:
              jar包是uploadbean.jar
              UploadBean 使用的是javazoom.upload.UploadBean

              String filename = user.getUserName() + Constant.getDate() + ".lst";  //信息索引文件
              String bodyFileName = Constant.getDate() + ".tel"; //電話文件
              String messageFileName = Constant.getDate() + ".txt"; //彩信的文本內(nèi)容。
              String pictureName = Constant.getDate() +filePostfix ;  //圖片名稱
              
              UploadBean upload = new UploadBean();
              upload.setParser(MultipartFormDataRequest.COSPARSER);
              upload.setWhitelist(Constant.WHITELIST);
              upload.setFolderstore(Constant.PATH);

              telStr = strBuff.toString().trim();
              FileOutputStream bodyfos = new FileOutputStream(new File(Constant.PATH, bodyFileName));
              BufferedWriter bodytbw = new BufferedWriter(new OutputStreamWriter(bodyfos, "GBK"));
              bodytbw.write("\"" + telStr + "\"");
              bodytbw.flush();
              bodytbw.close();
              bodyfos.close();

              生成的文件名稱有中文。
              FileOutputStream fos = new FileOutputStream(new File(Constant.PATH, new String(filename.getBytes("GBK"))));
              BufferedWriter stdout = new BufferedWriter(new OutputStreamWriter(fos, "GBK"));
              stdout.write(sb.toString());//sb.toString()是寫入文件的內(nèi)容。
              stdout.flush();
              stdout.close();
              fos.close();

          posted on 2011-06-16 11:15 生命的綻放 閱讀(1399) 評論(0)  編輯  收藏 所屬分類: JAVA

          <2011年6月>
          2930311234
          567891011
          12131415161718
          19202122232425
          262728293012
          3456789

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(5)

          隨筆分類(94)

          隨筆檔案(93)

          文章分類(5)

          文章檔案(5)

          相冊

          JAVA之橋

          SQL之音

          兄弟之窗

          常用工具下載

          積分與排名

          最新評論

          閱讀排行榜

          主站蜘蛛池模板: 玉山县| 舒兰市| 奉节县| 宝丰县| 永吉县| 长岛县| 九龙坡区| 藁城市| 金溪县| 龙门县| 阿勒泰市| 嫩江县| 固阳县| 大埔区| 贵阳市| 古蔺县| 辉县市| 正镶白旗| 昌吉市| 斗六市| 莱州市| 长海县| 肃宁县| 桃江县| 宜丰县| 珲春市| 周至县| 嘉祥县| 叙永县| 东乡| 铜陵市| 宜川县| 无为县| 毕节市| 和静县| 阳原县| 彭泽县| 霍山县| 扬州市| 阿拉善左旗| 太湖县|