20181127

2018年11月27日星期二php

 

转到linux,在httpd默认放网站路径编写一个cw.jspjava

<%python

out.print(2>1);linux

 

%>web

 

复制cw.jsp到tomcat默认放网站路径sql

 

 

主机浏览器分别访问  http://linuxip/cw.jsp   数据库

     http://linuxip:8080/cw.jsp    右键查看源文件数组

 

find   /     -name   “cw*.java”    -mmin  -20浏览器

 

 

httpd  web服务器跨平台,支持perl、php、python等写的网站tomcat

 

tomcat支持jsp写的网站

 

java 怎么生成随机数?         Math.random() 

 

new  Math();  //error

 

new  System(); 

 

权限修饰:

 

什么是实例? 什么是单例?怎么写单例类?

cw.java:

private  class  cw{

    //error

 

解释语句

public static final Boolean TRUE = new Boolean(true);

 

每一个基本数据类型都有一个对应的类,这个类中定义了不少与相应基本数据类型处理相关的函数

    System.out.println(  Integer.toString(15, 2) );    

       System.out.println(Integer.parseInt("1111a"));

  

     Integer l=128;    

       

        System.out.println(k==l);

        System.out.println(k.equals(l));

        System.out.println("hello".equals(new String("hello")));

  

用一行代码输出一个 \    

 

\表示路径要写两个,用/表示路径写一个

 

写一个函数,将一个字符串反过来

String  reverseString  str{

}

 

System.out.println("abc".indexOf("bc"));

System.out.println("abc".indexOf("bca"));

 

 结果(          ) 

class test{

   public static void main(String[] args) {

      String s1="a";

      String s2="ab";

      String s3="b";

      String s4=s1+s3;

      String s5=s1.concat(s3);   

   }

}

多少个()对象   

String  和StringBuffer的区别?

 

java怎么定义数组?

java.sql.Date    java.util.Date

 

Oracle 中有以下表  : 

py(id int primary key, rq date);

使用insert增长一条数据

 

用一个java语句输出“--  ::秒”    格式的日期

 

System.out.println("Current Date: " +

 new SimpleDateFormat ("yyyy-MM-dd hh:mm:ss").format(new Date())

);

 

 

class test  {

   public static void main(String[] args) {

      System.out.println(System.currentTimeMillis());

      Thread.sleep(5000);  //error

      System.out.println(System.currentTimeMillis());     

   }

}

 

class test  {

   public static void main(String[] args) throws InterruptedException {

      System.out.println(System.currentTimeMillis());

      Thread.sleep(5000);

      System.out.println(System.currentTimeMillis());     

   }

}

怎么计算某段代码执行耗时?

 

 

linux:使用grep查找一个文件中138  135开头的手机号

java 匹配一个email格式

 

test.java

 

class  Swap{

   int  a;

   static int b;

}

class  Test{

static  void  swap(Swap a,Swap b){

}

public static void main(String …args){

    Swap a=new Swap();

a.a=10;a.b=20;

Swap b=new Swap();

b.a=20;b.b=40;

swap(a,b);

System.out.println(a.a+a.b+b.a);

}

}

运行结果(                        

 

class Swap {

   int a;

   static int b;

}

 

class Test {

   static void swap(Swap a, Swap b) {

   }

 

   static void swap(int a,int b){

      int c=a;

      a=b;

      b=c;

   }

  

   public static void main(String... args) {

      Swap a = new Swap();

      a.a = 10;

      a.b = 20;

      Swap b = new Swap();

      b.a = 20;

      b.b = 40;

      swap(a.a, b.b);

System.out.println(a.a);

      System.out.println(a.a + a.b + b.a);

   }

}

 

运行结果(            

class Swap {

   int a;

   int b;

}

class Test {

   static void swap(Swap a, Swap b) {

      Swap c=a;       a=b;         b=c;

   }

   static void swap(int a,int b){

      int c=a;        a=b;         b=c;

   } 

   public static void main(String... args) {

      Swap a = new Swap();

      a.a = 10;           a.b = 30;

      Swap b = new Swap();

      b.a = 20;          b.b = 40;

      swap(a,b);

      System.out.println(a.a + a.b + b.a);

   }

}

运行结果(            

 

 

class Swap {

   int a;

   int b;

}

class Test {

   static void swap(Swap a, Swap b) {

      Swap c=a

      a.a=b.a;    

      b.a=c.b;

   }

   static void swap(int a,int b){

      int c=a;        a=b;         b=c;

   } 

   public static void main(String... args) {

      Swap a = new Swap();

      a.a = 10;           a.b = 30;

      Swap b = new Swap();

      b.a = 40;          b.b = 80;

      swap(a,b);

      System.out.println(a.a + a.b + b.a);

   }

}

运行结果(            

 

 

 

画出上面3个程序内存结构图

 

 

 

数据库的数据类型分

数值型(number/numeric/decimal之一关键字表示)

字符型(char/varchar)

日期型(date/datetime/timestamp之一) 

大字段型(clob/blob     text/image  ….)

 

输入输出流

 

全部的文件能够分两大类型

数据库怎么表示这两类文件,

Oracle用 clob 类型存储纯文本文件内容  blob类型存储有二进制格式的文件内容

 

 

纯文本文件(用记事本打开能看到文件原内容)

 

带二进制格式(用记事本看不到原内容)

 

java怎么读写这两类文件?

class Cp { 

  

   public static void main(String... args) {

     

      if (args.length!=2) {

         System.out.println("usage: java prog  srcFile dstFile");

         System.exit(-1);

      }

      System.out.println("end");

     

   }

}

运行结果(      )

怎么运行程序(             )能够看到(end)结果

class Cp

  

   public static void main(String... args) {

     

      if (args.length!=2) {

         System.out.println("usage: java Cp  srcFile dstFile");

         System.exit(-1);

      }

     

      FileInputStream  fin=null;

      FileOutputStream fout=null;

      // Unhandled exception type FileNotFoundException

         // 解决异常两种形式:本身捕捉异常try{}catch(Exception e){} ,本身不处理扔掉异常throws

 

      fin=new FileInputStream(args[0]);

      fout=new FileOutputStream(args[1]);    

     

      System.out.println("end");

     

   }

}

 

class Cp {

 

   public static void main(String... args) {

 

      if (args.length != 2) {

         System.out.println("usage: java  Cp  srcFile dstFile");

         System.exit(-1);

      }

 

      FileInputStream fin = null;

      FileOutputStream fout = null;

 

      try {

         fin = new FileInputStream(args[0]);        

         fout = new FileOutputStream(args[1]);      

      } catch (Exception e) {

                System.out.println(e.getMessage());

      }

 

      System.out.println("end");

 

   }

}

 

打开命令行,切换到bin目录,

运行 java Cp  aaaaaa    bbbb回车看什么结果

提醒:若是类在包中,则java  包名.Cp  aaaaa   bbbb

 

class Cp {

 

   public static void main(String... args) throws IOException {

      if (args.length != 2) {

         System.out.println("usage: java Cp  srcFile dstFile");

         System.exit(-1);

      }

      FileInputStream fin = null;

      FileOutputStream fout = null;

      try {

         fin = new FileInputStream(args[0]);

         fout = new FileOutputStream(args[1]);

         int c;

 

         while ((c = fin.read()) != -1) {

            fout.write(c);

         }

 

      } catch (Exception e) {

         System.out.println(e.getMessage());

      } finally {

         // 主要用来释放资源,好比关闭文件,关闭网络链接

         if (fin != null)

            fin.close();

         if (fout != null)

            fout.close();

      }

      System.out.println("end");

   }

}

用以上程序复制一个图片文件和纯文本文件,打开复制的文件

class Cp2 {

   public static void main(String... args) throws IOException {

      if (args.length != 2) {

         System.out.println("usage: java Cp2  srcFile dstFile");

         System.exit(-1);

      }

      FileReader fr=null;

      FileWriter  fw=null;

     

      try {

         fr=new FileReader(args[0]);

         fw=new FileWriter(args[1]);

         int c;     

         while (    ( c=fr.read()    )   !=-1          ) {

            fw.write(c);

         }       

      } catch (Exception e) {

         System.out.println(e.getMessage());

      }finally {

         if(fr!=null) fr.close();

         if(fw!=null) fw.close();

      }    

      System.out.println("end");

   }

}

 

用以上程序复制一个图片文件和纯文本文件,打开复制的文件

 

 

 

自习实践:

 

1linux:使用grep查找一个文件中138  135开头的手机号

2java 匹配一个email格式

3 画数据交换3个程序内存结构

4 java_tutorial.pdf18  Files and  I/O再找两个程序运行

5 Oracle 中有以下表  :  py(id int primary key, rq date);

使用insert增长一条数据,其中rq是你的出生日期

相关文章
相关标签/搜索