Java && C#

          要學(xué)得東西很多,但我們的時間卻不是很多!
          數(shù)據(jù)加載中……

          2007年3月27日

          點點滴滴

               N長時間沒有來了.......
               忙中偷閑,整理點代碼。
               /** 
               *  復(fù)制單個文件 
               *  @param  oldPath  String  原文件路徑  如:c:/fqf.txt 
               *  @param  newPath  String  復(fù)制后路徑  如:f:/fqf.txt 
               *  @return  boolean 
               */ 
             public  void  copyFile(String  oldPath,  String  newPath) 
             { 
                 try  { 
                     int  bytesum  =  0; 
                     int  byteread  =  0; 
                     File  oldfile  =  new  File(oldPath); 
                     if  (oldfile.exists())  {  //文件存在時 
                         InputStream  inStream  =  new  FileInputStream(oldPath);  //讀入原文件 
                         FileOutputStream  fs  =  new  FileOutputStream(newPath); 
                         byte[]  buffer  =  new  byte[1444]; 
                         int  length; 
                         while  (  (byteread  =  inStream.read(buffer))  !=  -1)  { 
                             bytesum  +=  byteread;  //字節(jié)數(shù)  文件大小 
                             System.out.println(bytesum); 
                             fs.write(buffer,  0,  byteread); 
                         } 
                         inStream.close(); 
                     } 
                 } 
                 catch  (Exception  e)  { 
                     System.out.println("復(fù)制單個文件操作出錯"); 
                     e.printStackTrace();  
                 }  
             }  

          //保存文件的方法
          public String Savefiles(FormFile file,String path)
           {  
            String fileName= file.getFileName();
            String contentType = file.getContentType();
            String size = (file.getFileSize() + " bytes");
            try
            {
             ByteArrayOutputStream baos = new ByteArrayOutputStream();
             InputStream stream = file.getInputStream();
             OutputStream bos = new FileOutputStream(path+fileName);
             int bytesRead = 0;
             byte[] buffer = new byte[8192];
             while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
              bos.write(buffer, 0, bytesRead);
             }
             bos.close();      
             stream.close();  
            }
            catch (IOException e) {
             return e.getMessage();
            }
            return "1";
           }

          //生成15位的字符串
          public String GenTradeId()
           {
            String tradeId = "";
            RandomStrg.setCharset("a-zA-Z0-9");  
            RandomStrg.setLength("15");  
            try
            {
             RandomStrg.generateRandomObject();
             tradeId=RandomStrg.getRandom();   
            }
            catch (Exception e)
            {    
            }
            return tradeId;  
           }

          /**
            * 刪除字符串中的空格,至多只保留一個空格
            * 
            * @String txt:輸入需要處理的字符串
            * @return String :返回處理后的字符串
            * 
            */
           public String deleteWhitespace(String txt){
            if((txt!=null)&&(txt.trim().length()>1)){
             
            }
            else{
             return "";
            }
            
            txt = txt.replaceAll("\n"," ").replaceAll("\t"," ");
            String temp="";
            try{
             int flag =0,num=0;
             char c = 'x';
             StringBuffer sb = new StringBuffer("");
             for(int x=0;x<txt.length();x++){
              c = txt.charAt(x);
              if((c==' ')&&(flag==0)){
               sb.append(c);
               flag =1;
              }
              else if((c!=' ')){
               sb.append(c);
               flag =0;
              }
             }
             temp = sb.toString().trim();
            }
            catch(Exception e){
             ;
            }
            return temp;
           }

          posted @ 2007-08-08 11:03 Bill111 閱讀(1536) | 評論 (0)編輯 收藏
          JavaScript Example

               摘要: 1.文本框焦點問題onBlur:當失去輸入焦點后產(chǎn)生該事件onFocus:當輸入獲得焦點后,產(chǎn)生該文件Onchange:當文字值改變時,產(chǎn)生該事件Onselect:當文字加亮后,產(chǎn)生該文件 <input type="text" value="郭強" onfocus="if(value=='郭強') {value=''}" onblur="if (value=='')...  閱讀全文

          posted @ 2007-03-27 17:18 Bill111 閱讀(2254) | 評論 (0)編輯 收藏
          主站蜘蛛池模板: 大关县| 竹溪县| 海原县| 乐昌市| 旌德县| 迁安市| 张掖市| 于都县| 柳江县| 甘谷县| 庄河市| 南康市| 孟州市| 苍溪县| 大埔县| 和平县| 宝丰县| 胶州市| 奉新县| 依兰县| 富蕴县| 霸州市| 察哈| 宁蒗| 北碚区| 穆棱市| 视频| 汝南县| 清河县| 弥渡县| 东宁县| 南丹县| 大港区| 普陀区| 长宁县| 西安市| 措美县| 阿图什市| 新民市| 蓬莱市| 湛江市|