2006年12月27日

          第一個ITEXT的程序

          最近因為工作需要在看iText,以前都沒接觸過報表這一塊,從頭學習中。。。
          第一個ITEXT的程序
          //Step?1:?define?document
          Rectangle?rectPageSize?=?new?Rectangle(PageSize.A4);
          Document?document?
          =?new?Document(rectPageSize,50,50,40,40);

          Paragraph?paragraph1?
          =?new?Paragraph("Welcome?to?IText");
          paragraph1.setAlignment(Paragraph.ALIGN_CENTER);
          PdfPTable?table?
          =?new?PdfPTable(2);
          PdfPCell?cell?
          =?new?PdfPCell();
          cell.addElement(paragraph1);
          cell.setColspan(
          2);
          table.addCell(cell);
          cell?
          =?new?PdfPCell();
          cell.addElement(
          new?Paragraph("Test1"));
          table.addCell(cell);
          cell?
          =?new?PdfPCell();
          cell.addElement(
          new?Paragraph("Test2"));
          table.addCell(cell);

          //Step?2:?define?output
          PdfWriter.getInstance(document,new?FileOutputStream("test.pdf"));

          //Step?3:?open?document
          document.open();

          //Step?4:?add?elements
          document.add(table);

          //Step?5:?close?document
          document.close();

          posted @ 2006-12-27 16:24 EdwinWang 閱讀(437) | 評論 (0)編輯 收藏

          2006年12月21日

          試用Netbeans5.5

          今天嘗試了下Netbeans 5.5版本,個人感覺很不錯。一直都不太喜歡Eclipse,也許Eclipse給開發人員帶來了最靈活的IDE,可靈活是有代價的,裝個其他開發環境大概十到二十分鐘就好了,裝Eclipse加上搗鼓那些插件估計能搞上一天。
          試了下在Netbeans5.5下開發Swing,web,web service,JSF等一些功能,感覺還不錯。雖然一些圖形化的拖拉效果做的還不盡如人意,但已經很不錯了。據說還可以可視化開發Mobile程序,改天要試一下。
          雖然Netbeans的靈活性不如eclipse,但是功能還是很強大的,值得使用。個人感覺eclipse更適合玩IDE的人而不是用IDE的人使用。Just 個人意見,呵呵~~

          posted @ 2006-12-21 11:10 EdwinWang 閱讀(275) | 評論 (0)編輯 收藏

          2006年12月20日

          如何在JAVA程序中調用windows其他程序

          雖然JAVA是平臺無關性的,但是在企業中很多時候還是在為特定的系統在開發,會要求調用一些當前系統的其他程序或命令。最常見的是在WINDOWS中。其實JAVA是可以通過Runtime去調用系統中的一些程序的,下面是一個例子:

          try {
          ????????????ps?
          = ?Runtime.getRuntime().exec( " E:\\test.exe " );
          ????????????
          // ps?=?Runtime.getRuntime().exec("ipconfig");??----?For?execute?windows?commands
          ????????????
          // ps?=?Runtime.getRuntime().exec("E:\\test.bat");?----?For?run?BAT?files
          ????????????BufferedReader?in? = ? new ?BufferedReader( new ???InputStreamReader(ps.getInputStream()));
          ????????????String?inputLine;?
          ????????????
          while ((inputLine??? = ???in.readLine())??? != ??? null )? {??
          ????????????????result???
          += ???inputLine + " \n " ;
          ????????????}

          ????????????in.close();
          ????????????System.out.println(
          " Output: " ? + ?result);
          ????????????
          ????????}
          catch (Exception?ex) {
          ????????????System.out.println(
          " Error " ? + ?ex.getMessage());
          ????????}

          上面的代碼片斷中后面一部分是在取返回的參數,如果不需要可以不取。不取的話可能也就不需要取得到Process了。用這個方法可以運行windows中的exe或者bat文件。

          posted @ 2006-12-20 10:49 EdwinWang 閱讀(1166) | 評論 (1)編輯 收藏

          2006年12月19日

          手動SOAP Call WebService

          前不久公司接了個活,要求在Pnuts中Call WebService,本來是一件很容易的事,可不能添加第三方的類包給我造成了麻煩。不能使用Ajax等一些第三方的包,意味著我只能自己去解析SOAP協議,而在PNuts中雖然可以調JAVA的方法,但卻不適合寫很大的功能,最后采用了一種非常傻的做法,手動去拼SOAP消息的內容,寫在這作為對一些特殊需求的一種實現方式:

          try {
          ????postStr?
          = ?postStr? + ? " <?xml?version='1.0'?encoding='utf-8'?> " ;
          ????postStr?
          = ?postStr? + ? " <soap:Envelope?xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' " ;
          ????postStr?
          = ?postStr? + ? " ?xmlns:xsd='http://www.w3.org/2001/XMLSchema' " ;
          ????postStr?
          = ?postStr? + ? " ?xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'> " ;
          ????postStr?
          = ?postStr? + ? " <soap:Body> " ;
          ????postStr?
          = ?postStr? + ? " <exchangeData?xmlns='https://www.riverbed.com/mfg/DataExchange/'> " ;
          ????postStr?
          = ?postStr? + ? " <sender>Test</sender> " ;
          ????postStr?
          = ?postStr? + ? " <password>35b82957-c792-81ce-38e4-7c83ad3291ea</password> " ;
          ????postStr?
          = ?postStr? + ? " <transactionType>Test_Get_Data</transactionType> " ;
          ????postStr?
          = ?postStr? + ? " <data> " ;
          ????postStr?
          = ?postStr? + ?htmlEncode(data);
          ????postStr?
          = ?postStr? + ? " </data> " ;
          ????postStr?
          = ?postStr? + ? " </exchangeData> " ;
          ????postStr?
          = ?postStr? + ? " </soap:Body> " ;
          ????postStr?
          = ?postStr? + ? " </soap:Envelope> " ;

          ????URL?url?
          = ? new ?URL( " https://www.test.com/testdata.php " );
          ????HttpURLConnection?conn?
          = ?(HttpURLConnection)url.openConnection();
          ????conn.setDoOutput(
          true );
          ????conn.setRequestMethod(
          " POST " );
          ????conn.setRequestProperty(
          " Content-Type " , " text/xml " );
          ????conn.setRequestProperty(
          " Content-Length " ,?String.valueOf(postStr.length()));
          ????conn.setDoOutput(
          true );
          ????conn.setDoInput(
          true );
          ????conn.connect();
          ????PrintWriter?out?
          = ? new ?PrintWriter(conn.getOutputStream());??
          ????out.print(postStr);
          ????out.flush();
          ????out.close();
          ????BufferedReader?in?
          = ? new ?BufferedReader( new ???InputStreamReader(conn.getInputStream()));
          ????String?inputLine;
          ????
          while ((inputLine??? = ???in.readLine())??? != ??? null )? {
          ????????result???
          += ???inputLine + " \n " ;??
          ????}

          ????in.close();
          ????System.out.println(htmlDecode(result));
          }
          catch (Exception?ex) {
          ????System.out.println(
          " Error: " ? + ?ex.getMessage());
          }

          posted @ 2006-12-19 09:40 EdwinWang 閱讀(1016) | 評論 (0)編輯 收藏

          Begin~

          終于還是開了自己的BLOG,一直都有這個想法,可是工作太忙似乎沒什么空寫,這次換了工作,以此為機會開了BLOG。至于能不能堅持就寫多少是多少吧。起個名字叫一個人的BLOG就是因為估計自己這么懶更新速度很慢,應該沒人會看,呵呵~~就當是自己記錄一些事情的工具吧~~

          posted @ 2006-12-19 08:58 EdwinWang 閱讀(162) | 評論 (0)編輯 收藏

          僅列出標題  
          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          搜索

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 驻马店市| 阜城县| 怀安县| 泸水县| 当雄县| 通山县| 沛县| 清镇市| 保亭| 溆浦县| 喀喇| 乌海市| 双牌县| 阿瓦提县| 宁海县| 诸城市| 沂水县| 稻城县| 三穗县| 武川县| 邳州市| 松滋市| 饶平县| 江北区| 赤壁市| 池州市| 图们市| 怀远县| 塔河县| 凤翔县| 郧西县| 秦安县| 南召县| 平遥县| 都匀市| 北辰区| 禹州市| 伊宁县| 江西省| 会泽县| 鄂伦春自治旗|