數(shù)據(jù)加載中……

          本程序搜索文件中的字

               摘要: /** *//**  (C) 北大青鳥APTECH.  *   版權(quán)所有  */ /** *//**  * 本程序?qū)胨璧念?  */ import java.io.File; import java.io.BufferedR...  閱讀全文

          posted @ 2008-10-30 09:12 郭興華 閱讀(70) | 評論 (0)編輯 收藏
          本程序搜索文件中的字

               摘要: /** *//**  (C) 北大青鳥APTECH.  *   版權(quán)所有  */ /** *//**  * 本程序?qū)胨璧念?  */ import java.io.File; import java.io.BufferedR...  閱讀全文

          posted @ 2008-10-30 09:12 郭興華 閱讀(87) | 評論 (0)編輯 收藏
          本程序搜索文件中的字

               摘要: /** *//**  (C) 北大青鳥APTECH.  *   版權(quán)所有  */ /** *//**  * 本程序?qū)胨璧念?  */ import java.io.File; import java.io.BufferedR...  閱讀全文

          posted @ 2008-10-30 09:12 郭興華 閱讀(101) | 評論 (0)編輯 收藏
          判斷一個(gè)一個(gè)路徑是否是目錄

          /**  
           *   (C) 北大青鳥APTECH.
           *   版權(quán)所有
           
          */


          /**
           * 本程序?qū)胨璧念?
           
          */

          import java.io.File;

          /**
           * 本程序演示 File 類的使用.
           * 
          @version 1.0 2005 年 5 月 20 日
           * 
          @author Michael
           
          */


          class ListDirectory {

          /** 存儲要搜索的目錄名稱. */
              String directoryName;

          /** 聲明一個(gè) File 對象. */
              File fileObj;

          /** 
           * 構(gòu)造方法.
           * 
          @param name 是一個(gè)字符串
           
          */

              ListDirectory(String name) 
          {
                 directoryName 
          = name;
                 fileObj 
          = new File(name);
              }


          /** 
           * 顯示目錄和子目錄的方法.
           
          */

              
          void display() {
                 
          if (fileObj.isDirectory()) {
                    System.out.println(
          "目錄是 : " + directoryName);
                    String[] fileName 
          = fileObj.list();

                    
          for (int ctr = 0; ctr < fileName.length; ctr++{
                        File nextFileObj 
          = new File(directoryName + "/" + fileName[ctr]);

                        
          if (nextFileObj.isDirectory()) {
                           System.out.println(fileName[ctr] 
          + " 是一個(gè)目錄");
                        }
           else {
                           System.out.println(fileName[ctr] 
          + " 是一個(gè)文件");
                        }

                    }

                  }
           else {
                        System.out.println(directoryName 
          + " 不是一個(gè)有效目錄");
                  }

              }

          }


          /**
           * 本程序測試 ListDirectory 類.
           * 
          @version 1.0 2005 年 5 月 20 日
           * 
          @author Michael
           
          */


          class DirectoryTest {

          /** 
           * 構(gòu)造方法. 
           
          */

              
          protected DirectoryTest() {
              }


          /**
           * 這是一個(gè) main 方法.
           * 
          @param args 被傳遞至 main 方法
           
          */

              
          public static void main(String[] args) {
                  ListDirectory listObj 
          = new ListDirectory("java");
                  listObj.display();
              }

          }

          posted @ 2008-10-30 08:09 郭興華 閱讀(1085) | 評論 (0)編輯 收藏
          抽象類和方法的用法.

               摘要: /**//* 北大青鳥APTECH  * 版權(quán)所有  */ /** *//**  * 這個(gè)程序演示抽象類和方法的用法.  * @版本 1.0 2005 年 5 月 20 日  * @author M...  閱讀全文

          posted @ 2008-10-29 18:52 郭興華 閱讀(212) | 評論 (0)編輯 收藏
          java的多態(tài)

          /*  北大青鳥APTECH.
           *  版權(quán)所有
           
          */


          /**
           * 這個(gè)程序演示動態(tài)多態(tài)性的用法.
           * 
          @version 1.0 2005 年 5 月 20 日
           * 
          @author Michael
           
          */

          abstract class Shape {

              
          /** 存儲任何形狀的長. */
              
          protected double length;

              
          /** 存儲任何形狀的寬. */
              
          protected double width;

              
          /** 
               * 構(gòu)造方法.
               * 
          @param num 傳遞至構(gòu)造方法
               * 
          @param num1 傳遞至構(gòu)造方法
               
          */

              Shape(
          final double num , final double num1) {

              
          /** 初始化變量. */
                  length 
          = num;
                  width 
          = num1;
              }


              
          /**
               * 抽象方法.
               * 
          @return double 值
               
          */

              
          abstract double area();
          }


          /**
           * 這個(gè)類重寫父類的方法.
           * 
          @version 1.0 2005 年 5 月 20 日
           * 
          @author Michael
           
          */


          class Square extends Shape {

              
          /** 構(gòu)造方法.
               *
          @param num 傳遞至構(gòu)造方法的參數(shù)
               *
          @param num1 傳遞至構(gòu)造方法的參數(shù)
               
          */

              Square(
          final double num, final double num1) {
                  
          super(num, num1);
              }


              
          /**
               * 計(jì)算正方形的面積.
               * @return傳遞給構(gòu)造方法的 length
               
          */


              
          double area() {
                  System.out.println(
          "正方形的面積為:" );
                  
          return length * width;
              }

          }


          /**
           * 這個(gè)類重寫父類的方法.
           * 
          @version 1.0 2005 年 5 月 20 日
           * 
          @author Michael
           
          */


          class Triangle extends Shape {

              
          /** 構(gòu)造方法.
               *
          @param num 傳遞至構(gòu)造方法的參數(shù)
               *
          @param num1 傳遞至構(gòu)造方法的參數(shù)
               
          */

              Triangle(
          final double num, final double num1) {
                  
          super(num, num1);
              }


              
          /**
               * 計(jì)算三角形的面積.
               *
          @return double  傳遞給構(gòu)造方法的length
               
          */


              
          double area() {
                  System.out.println(
          "三角形的面積為:" );
                  
          return (0.5 * length * width);
              }

          }


          /**
           * 這個(gè)類測試對象引用.
           * 
          @version 1.0 2005 年 5 月 20 日
           * 
          @author Michael
           
          */


          public class CalculateArea {

              
          /** 構(gòu)造方法. */
              
          protected CalculateArea() {
              }


              
          /**
               * 這是 main 方法.
               * 
          @param arg 傳遞至 main 方法的參數(shù)
               
          */


              
          public static void main(final String[] arg) {
                  
          // 初始化變量
                  Shape fObj;
                  Square sqObj 
          = new Square(10 , 20);
                  Triangle trObj 
          = new Triangle(12 , 8);
                  fObj 
          = sqObj;
                  System.out.println(fObj.area());
                  fObj 
          = trObj;
                  System.out.println(fObj.area());
              }

          }

          posted @ 2008-10-29 07:39 郭興華 閱讀(135) | 評論 (0)編輯 收藏
          java數(shù)組的Copy

          /**
          * 測試數(shù)組元素拷貝
          */
          public class ArrayCopy
          {
          public static void main(String[] args)
          {
          ArrayCopy aCopy
          = new ArrayCopy();
          int[] a = {1, 2, 3, 4, 5};
          int[] b = {10,20,30,40,50};
          aCopy.copy(a, b);

          }

          public void copy(int[] from, int[] to)
          {
          System.out.println(
          "第一個(gè)數(shù)組中的元素");
          for (int i = 0; i < from.length; i++)
          {
          System.out.print(
          " " + from[i]);//打印出數(shù)組中的每一個(gè)元素
          }
          System.out.println(
          "\n");

          System.out.println(
          "第二個(gè)數(shù)組中的元素");
          for (int i = 0; i < to.length; i++)
          {
          System.out.print(
          " " + to[i]);//打印出數(shù)組中的每一個(gè)元素
          }

          System.out.println(
          "\n\n將第一個(gè)數(shù)組拷貝到第二個(gè)數(shù)組\n");
          System.arraycopy(from,
          2, to, 0, 3);

          System.out.println(
          "拷貝完成后第二個(gè)數(shù)組中的元素");
          for (int i = 0; i < to.length; i++)
          {
          System.out.print(
          " " + to[i]);//打印出數(shù)組中的每一個(gè)元素
          }
          }
          }

          輸出結(jié)果是3 4 5 40 50

          posted @ 2008-10-28 10:11 郭興華 閱讀(183) | 評論 (0)編輯 收藏
          JDBC連接SQLSERVER

               摘要: <%@page language="java" import="java.util.*,java.sql.*,Oper.*,voo.*" pageEncoding="GBK"%> <table border=1> <tr>     <th>編號</th>...  閱讀全文

          posted @ 2008-10-26 09:46 郭興華 閱讀(1822) | 評論 (0)編輯 收藏
          jsp讀取*.TXT

          package mypack;
          import java.io.*;

          public class ReadText{
              
          public String getShiGe(){
                  
          //File f=new File("guoxinghua.txt");
                  File f=new File(this.getClass().getResource("guoxinghua.txt").toURI());
                  
          try{
                      FileReader fr
          =new FileReader(f);
                      BufferedReader buff
          =new BufferedReader(fr);//BufferedReader用于讀取文本
                      String line="";
                      
          while((line=buff.readLine())!=null)
                      
          {
                          retstr
          +line+"<br>";
                          }

                          buff.close();
                          }

                      
          catch(Exception e)
                      
          {
                          e.printStackTrace();
                          
                          }

                          
                          
                          
          return retstr;
                          }

              }



          <%@page language="java" import="java.util.*,mypack" page Encoding="GBK"%>
          <%
          ReadText rt
          =new ReadText();
          %>
          <%=rt.getShiGe()%>

          posted @ 2008-10-26 07:20 郭興華 閱讀(765) | 評論 (1)編輯 收藏
          java1.5注解(二)


          import java.util.Date;
          import java.util.Map;
          import java.util.TreeMap;
          class  SuppressWarningsTest
          {
              
          public static void main(String[] args) 
              
          {
                  Map
          <String,Date> map=new TreeMap<String,Date>();
                  map.put(
          "hello",new Date());
                  System.out.println(map.get(
          "hello"));
              }

          }





          import java.util.Date;
          import java.util.Map;
          import java.util.TreeMap;
          class  SuppressWarningsTest2
          {
              
          public static void main(String[] args) 
              
          {
                  Map map
          =new TreeMap();
                  
          //Map<String,Date> map=new TreeMap<String,Date>();
                  map.put("hello",new Date());
                  System.out.println(map.get(
          "hello"));
              }

          }




          import java.util.Date;
          import java.util.Map;
          import java.util.TreeMap;
          class  SuppressWarningsTest3
          {
              @SuppressWarnings(
          "unchecked")
              
          public static void main(String[] args) 
              
          {
                  Map map
          =new TreeMap();
                  
          //Map<String,Date> map=new TreeMap<String,Date>();
                  map.put("hello",new Date());
                  System.out.println(map.get(
          "hello"));
              }

          }






          import java.util.Date;
          import java.util.Map;
          import java.util.TreeMap;
          class DeprecatedTest 
          {
              
          public void doSomething(){
              System.out.println(
          "guoxinghua");
              }

              
          public static void main(String[] args) 
              
          {
                  DeprecatedTest test
          =new DeprecatedTest();
                  test.doSomething();
                  
              }

          }


          class  SuppressWarningsTest2
          {
              
          public static void main(String[] args) 
              
          {
                  Map map
          =new TreeMap();
                  
          //Map<String,Date> map=new TreeMap<String,Date>();
                  map.put("hello",new Date());
                  System.out.println(map.get(
          "hello"));
              }

          }




          import java.util.Date;
          import java.util.Map;
          import java.util.TreeMap;
          class DeprecatedTest 
          {
              
          public void doSomething(){
              System.out.println(
          "guoxinghua");
              }

              
          public static void main(String[] args) 
              
          {
                  DeprecatedTest test
          =new DeprecatedTest();
                  test.doSomething();
                  
              }

          }


          class  SuppressWarningsTest2
          {
              @SuppressWarnings(
          {"unchecked","deprecation"})
              
          public static void main(String[] args) 
              
          {
                  Map map
          =new TreeMap();
                  
          //Map<String,Date> map=new TreeMap<String,Date>();
                  map.put("hello",new Date());
                  System.out.println(map.get(
          "hello"));
                  DeprecatedTest test
          =new DeprecatedTest();
                  test.doSomething();
              }

          }


          posted @ 2008-10-26 00:21 郭興華 閱讀(361) | 評論 (0)編輯 收藏
          僅列出標(biāo)題
          共9頁: 上一頁 1 2 3 4 5 6 7 8 9 下一頁 
          主站蜘蛛池模板: 广东省| 东海县| 南陵县| 墨脱县| 宜州市| 汉寿县| 海南省| 宁化县| 马边| 建始县| 白水县| 娱乐| 连云港市| 民乐县| 耿马| 哈尔滨市| 迭部县| 沙田区| 库尔勒市| 顺义区| 靖州| 黄冈市| 洪洞县| 榆社县| 深州市| 广河县| 姚安县| 韶山市| 东乡县| 河北省| 醴陵市| 白沙| 泗阳县| 浏阳市| 深泽县| 奉贤区| 上虞市| 遵义县| 绥德县| 丰宁| 吉木乃县|