JAVA 基础知识学习18

目录

01转换流概述

* A: 转换流概述
    * a: 转换流概述
        * OutputStreamWriter 是字符流通向字节流的桥梁:可使用指定的字符编码表,将要写入流中的字符编码成字节
        * 将字符串按照指定的编码表转成字节,在使用字节流将这些字节写出去

02转换流_字符转字节的过程

* A: 转换流_字符转字节的过程
    * a.图解
        * 详见day24_source/转换流.JPG图片

03OutputStreamWriter写文本文件

* A: OutputStreamWriter写文本文件
        * a: OutputStreamWriter
            * java.io.OutputStreamWriter 继承Writer类
            * 就是一个字符输出流,写文本文件
            * write()字符,字符数组,字符串    
            * 字符通向字节的桥梁,将字符流转字节流
            * OutputStreamWriter 使用方式
                * 构造方法:
                    * OutputStreamWriter(OuputStream out)接收所有的字节输出流
                    * 字节输出流:  FileOutputStream       
                    * OutputStreamWriter(OutputStream out, String charsetName)
                    * String charsetName 传递编码表名字 GBK  UTF-8 
            * OutputStreamWriter 有个子类,  FileWriter
        * b: 案例代码

                public class OutputStreamWriterDemo {
                    public static void main(String[] args)throws IOException {
                //      writeGBK();
                        writeUTF();
                    }
                    /*
                     * 转换流对象OutputStreamWriter写文本
                     * 采用UTF-8编码表写入
                     */
                    public static void writeUTF()throws IOException{
                        //创建字节输出流,绑定文件
                        FileOutputStream fos = new FileOutputStream("c:\\utf.txt");
                        //创建转换流对象,构造方法保证字节输出流,并指定编码表是UTF-8
                        OutputStreamWriter osw = new OutputStreamWriter(fos,"UTF-8");
                        osw.write("你好");
                        osw.close();
                    }

                    /*
                     * 转换流对象 OutputStreamWriter写文本
                     * 文本采用GBK的形式写入
                     */
                    public static void writeGBK()throws IOException{
                        //创建字节输出流,绑定数据文件
                        FileOutputStream fos = new FileOutputStream("c:\\gbk.txt");
                        //创建转换流对象,构造方法,绑定字节输出流,使用GBK编码表
                        OutputStreamWriter osw = new OutputStreamWriter(fos);
                        //转换流写数据
                        osw.write("你好");

                        osw.close();
                    }
                }

04转换流_字节转字符流过程

* A: 转换流_字节转字符流过程
    * a: InputStreamReader          
        * java.io.InputStreamReader 继承 Reader
        * 字符输入流,读取文本文件
        * 字节流向字符的敲了,将字节流转字符流
        * 读取的方法:
            * read() 读取1个字符,读取字符数组
        * 技巧
            * OuputStreamWriter写了文件
            * InputStreamReader读取文件
        * OutputStreamWriter(OutputStream out)所有字节输出流
        * InputStreamReader(InputStream in) 接收所有的字节输入流
        * 可以传递的字节输入流: FileInputStream
        * InputStreamReader(InputStream in,String charsetName) 传递编码表的名字
    * b: 图解
        * 详见day24_source/转换流.JPG图片

05InputSteamReader读取文本文件

* A: InputSteamReader读取文本文件
    * a: 案例代码
    public class InputStreamReaderDemo {
                public static void main(String[] args) throws IOException {
            //      readGBK();
                    readUTF();
                }
                /*
                 *  转换流,InputSteamReader读取文本
                 *  采用UTF-8编码表,读取文件utf
                 */
                public static void readUTF()throws IOException{
                    //创建自己输入流,传递文本文件
                    FileInputStream fis = new FileInputStream("c:\\utf.txt");
                    //创建转换流对象,构造方法中,包装字节输入流,同时写编码表名
                    InputStreamReader isr = new InputStreamReader(fis,"UTF-8");
                    char[] ch = new char[1024];
                    int len = isr.read(ch);
                    System.out.println(new String(ch,0,len));
                    isr.close();
                }
                /*
                 *  转换流,InputSteamReader读取文本
                 *  采用系统默认编码表,读取GBK文件
                 */
                public static void readGBK()throws IOException{
                    //创建自己输入流,传递文本文件
                    FileInputStream fis = new FileInputStream("c:\\gbk.txt");
                    //创建转换流对象,构造方法,包装字节输入流
                    InputStreamReader isr = new InputStreamReader(fis);
                    char[] ch = new char[1024];
                    int len = isr.read(ch);
                    System.out.println(new String(ch,0,len));

                    isr.close();
                }
            }

06转换流子类父类的区别

* A: 转换流子类父类的区别
    * a: 继承关系
        OutputStreamWriter:
            |--FileWriter:
        InputStreamReader:
            |--FileReader;
    * b: 区别
        * OutputStreamWriter和InputStreamReader是字符和字节的桥梁:也可以称之为字符转换流。字符转换流原理:字节流+编码表。
        * FileWriter和FileReader:作为子类,仅作为操作字符文件的便捷类存在。
            当操作的字符文件,使用的是默认编码表时可以不用父类,而直接用子类就完成操作了,简化了代码。
        * 以下三句话功能相同
            * InputStreamReader isr = new InputStreamReader(new FileInputStream("a.txt"));//默认字符集。
            * InputStreamReader isr = new InputStreamReader(new FileInputStream("a.txt"),"GBK");//指定GBK字符集。
            * FileReader fr = new FileReader("a.txt");

07缓冲流概述

* A: 缓冲流概述
    * a: 概述
        * 可提高IO流的读写速度
        * 分为字节缓冲流与字符缓冲流 

08字节输出流缓冲流BufferedOutputStream

* A: 字节输出流缓冲流BufferedOutputStream
        * a: BufferedOutputStream
            * 字节输出流的缓冲流
            * java.io.BufferedOuputStream 作用: 提高原有输出流的写入效率
            * BufferedOuputStream 继承 OutputStream
            * 方法,写入 write 字节,字节数组            
            * 构造方法:
                * BufferedOuputStream(OuputStream out)
                * 可以传递任意的字节输出流, 传递的是哪个字节流,就对哪个字节流提高效率  

        * b: 案例代码
            public class BufferedOutputStreamDemo {
                public static void main(String[] args)throws IOException {
                    //创建字节输出流,绑定文件
                    //FileOutputStream fos = new FileOutputStream("c:\\buffer.txt");
                    //创建字节输出流缓冲流的对象,构造方法中,传递字节输出流
                    BufferedOutputStream bos = new
                            BufferedOutputStream(new FileOutputStream("c:\\buffer.txt"));

                    bos.write(55);

                    byte[] bytes = "HelloWorld".getBytes();

                    bos.write(bytes);

                    bos.write(bytes, 3, 2);

                    bos.close();
                }
            }

09字节输入流缓冲流BufferedInputStream

* A: 字节输入流缓冲流BufferedInputStream
        * a: BufferedInputStream
            * 字节输入流的缓冲流
            * 继承InputStream,标准的字节输入流
            * 读取方法  read() 单个字节,字节数组              
            * 构造方法:
                * BufferedInputStream(InputStream in)
                * 可以传递任意的字节输入流,传递是谁,就提高谁的效率
                * 可以传递的字节输入流 FileInputStream
        * b: 案例代码
            public class BufferedInputStreamDemo {
                public static void main(String[] args) throws IOException{
                    //创建字节输入流的缓冲流对象,构造方法中包装字节输入流,包装文件
                    BufferedInputStream bis = new 
                            BufferedInputStream(new FileInputStream("c:\\buffer.txt"));
                    byte[] bytes = new byte[10];
                    int len = 0 ;
                    while((len = bis.read(bytes))!=-1){
                        System.out.print(new String(bytes,0,len));
                    }
                    bis.close();
                }
            }

10四种文件复制方式的效率比较

* A:四种文件复制方式的效率比较
        * a: 四中复制方式
            * 字节流读写单个字节                    125250 毫秒
            * 字节流读写字节数组                    193    毫秒  OK
            * 字节流缓冲区流读写单个字节         1210   毫秒
            * 字节流缓冲区流读写字节数组            73     毫秒  OK        

        * b: 案例代码

            public class Copy {
                public static void main(String[] args)throws IOException {
                    long s = System.currentTimeMillis();
                    copy_4(new File("c:\\q.exe"), new File("d:\\q.exe"));
                    long e = System.currentTimeMillis();
                    System.out.println(e-s);
                }
                /*
                 * 方法,实现文件复制
                 *  4. 字节流缓冲区流读写字节数组
                 */
                public static void copy_4(File src,File desc)throws IOException{
                    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(src));
                    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(desc));
                    int len = 0 ;
                    byte[] bytes = new byte[1024];
                    while((len = bis.read(bytes))!=-1){
                        bos.write(bytes,0,len);
                    }
                    bos.close();
                    bis.close();
                }
                /*
                 * 方法,实现文件复制
                 *  3. 字节流缓冲区流读写单个字节
                 */
                public static void copy_3(File src,File desc)throws IOException{
                    BufferedInputStream bis = new BufferedInputStream(new FileInputStream(src));
                    BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(desc));
                    int len = 0 ;
                    while((len = bis.read())!=-1){
                        bos.write(len);
                    }
                    bos.close();
                    bis.close();
                }

                /*
                 * 方法,实现文件复制
                 *  2. 字节流读写字节数组
                 */
                public static void copy_2(File src,File desc)throws IOException{
                    FileInputStream fis = new FileInputStream(src);
                    FileOutputStream fos = new FileOutputStream(desc);
                    int len = 0 ;
                    byte[] bytes = new byte[1024];
                    while((len = fis.read(bytes))!=-1){
                        fos.write(bytes,0,len);
                    }
                    fos.close();
                    fis.close();
                }

                /*
                 * 方法,实现文件复制
                 *  1. 字节流读写单个字节
                 */
                public static void copy_1(File src,File desc)throws IOException{
                    FileInputStream fis = new FileInputStream(src);
                    FileOutputStream fos = new FileOutputStream(desc);
                    int len = 0 ;
                    while((len = fis.read())!=-1){
                        fos.write(len);
                    }
                    fos.close();
                    fis.close();
                }
            }

11字符输出流缓冲流BufferedWriter

* A: 字符输出流缓冲流BufferedWriter
        * a: BufferedWriter
            * 字符输出流缓冲区流
            * java.io.BufferedWriter 继承 Writer
            * 写入方法 write () 单个字符,字符数组,字符串

            * 构造方法:
                * BufferedWriter(Writer w)传递任意字符输出流
                * 传递谁,就高效谁
                * 能传递的字符输出流 FileWriter, OutputStreamWriter
        * b: 案例代码
            public class BufferedWrierDemo {
                public static void main(String[] args) throws IOException{
                    //创建字符输出流,封装文件
                    FileWriter fw = new FileWriter("c:\\buffer.txt");
                    BufferedWriter bfw = new BufferedWriter(fw);

                    bfw.write(100);
                    bfw.flush();
                    bfw.write("你好".toCharArray());
                    bfw.flush();


                    bfw.write("你好");

                    bfw.flush();


                    bfw.write("我好好");

                    bfw.flush();

                    bfw.write("大家都好");
                    bfw.flush();

                    bfw.close();

                }
            }

12字符输出流缓冲流BufferedWriter特有方法newLine

    * A: 字符输出流缓冲流BufferedWriter特有方法newLine
        * a: 方法介绍
            * void  newLine() 写换行

            * newLine()文本中换行, \r\n也是文本换行
            * 方法具有平台无关性
            * Windows  \r\n
            * Linux    \n

            * newLine()运行结果,和操作系统是相互关系
            * JVM: 安装的是Windows版本,newLine()写的就是\r\n
            * 安装的是Linux版本,newLine()写的就是\n
            /*
             *  将数据源 c:\\a.txt
             *  复制到 d:\\a.txt  数据目的
             *  字节输入流,绑定数据源
             *  字节输出流,绑定数据目的
             *  
             *  输入,读取1个字节
             *  输出,写1个字节
             */
        * b: 案例代码
            public class BufferedWrierDemo {
                public static void main(String[] args) throws IOException{
                    //创建字符输出流,封装文件
                    FileWriter fw = new FileWriter("c:\\buffer.txt");
                    BufferedWriter bfw = new BufferedWriter(fw);

                    bfw.write(100);
                    bfw.flush();
                    bfw.write("你好".toCharArray());
                    bfw.flush();

                    bfw.write("你好");
                    bfw.newLine();
                    bfw.flush();


                    bfw.write("我好好");
                    bfw.newLine();
                    bfw.flush();

                    bfw.write("大家都好");
                    bfw.flush();

                    bfw.close();

                }

            }

13字符输入流缓冲流BufferedReader

* A: 字符输入流缓冲流BufferedReader
    * a: 概述
        * 从字符输入流中读取文本,缓冲各个字符,从而实现字符、数组和行的高效读取
        * public String readLine() 读取一个文本行,包含该行内容的字符串,不包含任何行终止符,如果已到达流末尾,则返回 null

14字符输入流缓冲流BufferedReader读取文本行

* A: 字符输入流缓冲流BufferedReader读取文本行
        * a: BufferedReader
            * 字符输入流缓冲流
            * java.io.BufferedReader 继承 Reader
            * 读取功能 read() 单个字符,字符数组
            * 构造方法:
                * BufferedReader(Reader r)
                * 可以任意的字符输入流
                   FileReader  InputStreamReader       
            * BufferedReader自己的功能
                * String readLine() 读取文本行 \r\n   
                    * 方法读取到流末尾,返回null
        * b: 小特点
             * 获取内容的方法一般都有返回值
             * int 没有返回的都是负数
             * 引用类型 找不到返回null
             * boolean 找不到返回false

        * c: 案例代码
            public class BufferedReaderDemo {
                public static void main(String[] args) throws IOException {
                    int lineNumber = 0;
                    //创建字符输入流缓冲流对象,构造方法传递字符输入流,包装数据源文件
                    BufferedReader bfr = new BufferedReader(new FileReader("c:\\a.txt"));
                    //调用缓冲流的方法 readLine()读取文本行
                    //循环读取文本行, 结束条件 readLine()返回null
                    String line = null;
                    while((line = bfr.readLine())!=null){
                        lineNumber++;
                        System.out.println(lineNumber+"  "+line);
                    }
                    bfr.close();
                }
            }

            /*
             * String line = bfr.readLine();
                    System.out.println(line);

                    line = bfr.readLine();
                    System.out.println(line);

                    line = bfr.readLine();
                    System.out.println(line);

                    line = bfr.readLine();
                    System.out.println(line);

                    line = bfr.readLine();
                    System.out.println(line);
             */

15字符流缓冲区流复制文本文件

* A: 字符流缓冲区流复制文本文件
        * a: 案例代码
            /*
             *  使用缓冲区流对象,复制文本文件
             *  数据源  BufferedReader+FileReader 读取
             *  数据目的 BufferedWriter+FileWriter 写入
             *  读取文本行, 读一行,写一行,写换行
             */
            public class Copy_1 {
                public static void main(String[] args) throws IOException{
                    BufferedReader bfr = new BufferedReader(new FileReader("c:\\w.log"));   
                    BufferedWriter bfw = new BufferedWriter(new FileWriter("d:\\w.log"));
                    //读取文本行, 读一行,写一行,写换行
                    String line = null;
                    while((line = bfr.readLine())!=null){
                        bfw.write(line);
                        bfw.newLine();
                        bfw.flush();
                    }
                    bfw.close();
                    bfr.close();
                }
            }

16IO流对象的操作规律

* A: IO流对象的操作规律
    * a: 明确一:要操作的数据是数据源还是数据目的。
        * 源:InputStream    Reader
        * 目的:OutputStream Writer
        * 先根据需求明确要读,还是要写。

    * b: 明确二:要操作的数据是字节还是文本呢?
        * 源:
            * 字节:InputStream
            * 文本:Reader
        * 目的:
            * 字节:OutputStream
            * 文本:Writer
    * c: 明确三:明确数据所在的具体设备。
        * 源设备:
            * 硬盘:文件  File开头。
            * 内存:数组,字符串。
            * 键盘:System.in;
            * 网络:Socket
        * 目的设备:
            * 硬盘:文件  File开头。
            * 内存:数组,字符串。
            * 屏幕:System.out
            * 网络:Socket
            * 完全可以明确具体要使用哪个流对象。
    * d: 明确四:是否需要额外功能呢?
        * 额外功能:
            * 转换吗?转换流。InputStreamReader OutputStreamWriter
            * 高效吗?缓冲区对象。BufferedXXX
            * 已经明确到了具体的体系上。

01Properties集合的特点

* A: Properties集合的特点
    * a: Properties类介绍
        * Properties 类表示了一个持久的属性集。Properties 可保存在流中或从流中加载。属性列表中每个键及其对应值都是一个字符串
    * b: 特点
        * Hashtable的子类,map集合中的方法都可以用。
        * 该集合没有泛型。键值都是字符串。
        * 它是一个可以持久化的属性集。键值可以存储到集合中,也可以存储到持久化的设备(硬盘、U盘、光盘)上。键值的来源也可以是持久化的设备。
        * 有和流技术相结合的方法。
    * c: 方法介绍
        * load(InputStream inputStream)  把指定流所对应的文件中的数据,读取出来,保存到Propertie集合中
        * load(Reader reader) 按简单的面向行的格式从输入字符流中读取属性列表(键和元素对)
        * store(OutputStream outputStream,String commonts) 把集合中的数据,保存到指定的流所对应的文件中,参数commonts代表对描述信息
        * stroe(Writer writer,String comments) 以适合使用 load(Reader) 方法的格式,将此 Properties 表中的属性列表(键和元素对)写入输出字符

02Properties集合存储键值对

* A: Properties集合存储键值对      
        * a: 方法介绍
            *  集合对象Properties类,继承Hashtable,实现Map接口
            *  可以和IO对象结合使用,实现数据的持久存储
            * 使用Properties集合,存储键值对
            * setProperty等同与Map接口中的put
            * setProperty(String key, String value)
            * 通过键获取值, getProperty(String key)
        * b: 案例代码
            public class PropertiesDemo {
                public static void main(String[] args)throws IOException {
                    function_2();
                }
                /*
                 * 使用Properties集合,存储键值对
                 * setProperty等同与Map接口中的put
                 * setProperty(String key, String value)
                 * 通过键获取值, getProperty(String key)
                 */
                public static void function(){
                    Properties pro = new Properties();
                    pro.setProperty("a", "1");
                    pro.setProperty("b", "2");
                    pro.setProperty("c", "3");
                    System.out.println(pro);

                    String value = pro.getProperty("c");
                    System.out.println(value);

                    //方法stringPropertyNames,将集合中的键存储到Set集合,类似于Map接口的方法keySet
                    Set<String> set = pro.stringPropertyNames();
                    for(String key : set){
                        System.out.println(key+"..."+pro.getProperty(key));
                    }
                }
            }

03Properties集合的方法load

* A: Properties集合的方法load
        * a: 方法介绍
            * Properties集合特有方法 load
            * load(InputStream in)
            * load(Reader r)
            * 传递任意的字节或者字符输入流
            * 流对象读取文件中的键值对,保存到集合

        * b: 案例代码       
                public class PropertiesDemo {
                    public static void main(String[] args)throws IOException {
                        function_1();
                    }                                   
                    /*
                     * Properties集合特有方法 load
                     * load(InputStream in)
                     * load(Reader r)
                     * 传递任意的字节或者字符输入流
                     * 流对象读取文件中的键值对,保存到集合
                     */
                    public static void function_1()throws IOException{
                        Properties pro = new Properties();
                        FileReader fr = new FileReader("c:\\pro.properties");
                        //调用集合的方法load,传递字符输入流
                        pro.load(fr);
                        fr.close();
                        System.out.println(pro);
                    }                   
                }

04Properties集合的方法store

* A: Properties集合的方法store
        * a: 方法介绍           
            * Properties集合的特有方法store
            * store(OutputStream out)
            * store(Writer w)
            * 接收所有的字节或者字符的输出流,将集合中的键值对,写回文件中保存
        * b: 案例代码
            public class PropertiesDemo {
                public static void main(String[] args)throws IOException {
                    function_2();
                }
                /*
                 * Properties集合的特有方法store
                 * store(OutputStream out)
                 * store(Writer w)
                 * 接收所有的字节或者字符的输出流,将集合中的键值对,写回文件中保存
                 */
                public static void function_2()throws IOException{
                    Properties pro = new Properties();
                    pro.setProperty("name", "zhangsan");
                    pro.setProperty("age", "31");
                    pro.setProperty("email", "123456789@163.com");
                    FileWriter fw = new FileWriter("c:\\pro.properties");
                    //键值对,存回文件,使用集合的方法store传递字符输出流
                    pro.store(fw, "");
                    fw.close();
                }               
            }

05对象的序列化与反序列化

* A: 对象的序列化与反序列化
    * a: 基本概念
        * 对象的序列化
            * 对象中的数据,以流的形式,写入到文件中保存过程称为写出对象,对象的序列化
            * ObjectOutputStream将对象写道文件中,实现序列化
        * 对象的反序列化
            * 在文件中,以流的形式,将对象读出来,读取对象,对象的反序列化
            * ObjectInputStream 将文件对象读取出来

06ObjectOutputStream流写对象

* A: ObjectOutputStream流写对象
    * a: 简单介绍
         *  IO流对象,实现对象Person序列化,和反序列化
         *  ObjectOutputStream 写对象,实现序列化
         *  ObjectInputStream 读取对象,实现反序列化

    * b: 案例代码
    public class Person implements Serializable{
                public String name;
                public int age;
                public Person(String name, int age) {
                    super();
                    this.name = name;
                    this.age = age;
                }
                public Person(){}

                public String getName() {
                    return name;
                }
                public void setName(String name) {
                    this.name = name;
                }
                public int getAge() {
                    return age;
                }
                public void setAge(int age) {
                    this.age = age;
                }
                @Override
                public String toString() {
                    return "Person [name=" + name + ", age=" + age + "]";
                }               
            }

            public class ObjectStreamDemo {
                public static void main(String[] args)throws IOException, ClassNotFoundException {
            //      writeObject();
                    readObject();
                }
                /*
                 * ObjectOutputStream
                 * 构造方法: ObjectOutputStream(OutputSteam out)
                 * 传递任意的字节输出流
                 * void writeObject(Object obj)写出对象的方法
                 */
                public static void writeObject() throws IOException{
                    //创建字节输出流,封装文件
                    FileOutputStream fos = new FileOutputStream("c:\\person.txt");
                    //创建写出对象的序列化流的对象,构造方法传递字节输出流
                    ObjectOutputStream oos = new ObjectOutputStream(fos);
                    Person p = new Person("lisi",25);
                    //调用序列化流的方法writeObject,写出对象
                    oos.writeObject(p);
                    oos.close();
                }
            }

07ObjectInputStream流读取对象

* A: ObjectInputStream流读取对象
    * a: 简单介绍
        * ObjectInputStream
        * 构造方法:ObjectInputStream(InputStream in)
        * 传递任意的字节输入流,输入流封装文件,必须是序列化的文件
        * Object readObject()  读取对象
    * b: 案例代码
    /*
             *  IO流对象,实现对象Person序列化,和反序列化
             *  ObjectOutputStream 写对象,实现序列化
             *  ObjectInputStream 读取对象,实现反序列化
             */
            public class ObjectStreamDemo {
                public static void main(String[] args)throws IOException, ClassNotFoundException {
                    readObject();
                }
                /*
                 * ObjectInputStream
                 * 构造方法:ObjectInputStream(InputStream in)
                 * 传递任意的字节输入流,输入流封装文件,必须是序列化的文件
                 * Object readObject()  读取对象
                 */
                public static void readObject() throws IOException, ClassNotFoundException{
                    FileInputStream fis = new FileInputStream("c:\\person.txt");
                    //创建反序列化流,构造方法中,传递字节输入流
                    ObjectInputStream ois = new ObjectInputStream(fis);
                    //调用反序列化流的方法 readObject()读取对象
                    Object obj =ois.readObject();
                    System.out.println(obj);
                    ois.close();
                }               
            }

08静态不能序列化

* A: 静态不能序列化
    * a: 原因
        * 序列化是把对象数据进行持久化存储
        * 静态的东西不属于对象,而属于类

09transient关键字

* A: transient关键字
    * a: 作用
        * 被transient修饰的属性不会被序列化
        * transient关键字只能修饰成员变量

10Serializable接口的含义

* A:Serializable接口的含义
    * a: 作用
        * 给需要序列化的类上加标记。该标记中没有任何抽象方法
        * 只有实现了 Serializable接口的类的对象才能被序列化

11序列化中的序列号冲突问题

* A: 序列化中的序列号冲突问题
    * a: 问题产生原因
        * 当一个类实现Serializable接口后,创建对象并将对象写入文件,之后更改了源代码(比如:将成员变量的修饰符有private改成public),
            再次从文件中读取对象时会报异常
        * 见day25_source文件夹下的"序列号的冲突.JPG"文件

12序列化中自定义的序列号

    * A: 序列化中自定义的序列号
        * a: 定义方式
            * private static final long serialVersionUID = 1478652478456L;
                * 这样每次编译类时生成的serialVersionUID值都是固定的     

        * b: 案例代码
            public class Person implements Serializable{
                public String name;
                public /*transient阻止成员变量序列化*/ int age;
                //类,自定义了序列号,编译器不会计算序列号
                private static final long serialVersionUID = 1478652478456L;

                public Person(String name, int age) {
                    super();
                    this.name = name;
                    this.age = age;
                }
                public Person(){}

                public String getName() {
                    return name;
                }
                public void setName(String name) {
                    this.name = name;
                }
                public int getAge() {
                    return age;
                }
                public void setAge(int age) {
                    this.age = age;
                }
                @Override
                public String toString() {
                    return "Person [name=" + name + ", age=" + age + "]";
                }               
            }

###13打印流和特性
    * A: 打印流和特性
        * a: 概述
            * 打印流添加输出数据的功能,使它们能够方便地打印各种数据值表示形式.
            * 打印流根据流的分类:
                * 字节打印流 PrintStream
                * 字符打印流 PrintWriter
            * 方法:
                * void print(String str): 输出任意类型的数据,
                * void println(String str): 输出任意类型的数据,自动写入换行操作
        * b: 特点         
            * 此流不负责数据源,只负责数据目的
            * 为其他输出流,添加功能
            * 永远不会抛出IOException,但是可能抛出别的异常  
            * 两个打印流的方法,完全一致
            * 构造方法,就是打印流的输出目的端
            * PrintStream构造方法
                * 接收File类型,接收字符串文件名,接收字节输出流OutputStream
            * PrintWriter构造方法
                * 接收File类型,接收字符串文件名,接收字节输出流OutputStream, 接收字符输出流Writer

14打印流输出目的是File对象

* A: 打印流输出目的是File对象
    * a: 案例代码
public class PrintWriterDemo {
                public static void main(String[] args) throws  IOException {
                    function_3();

                }

                /*
                 * 打印流,向File对象的数据目的写入数据
                 * 方法print println  原样输出
                 * write方法走码表
                 */
                public static void function() throws FileNotFoundException{
                    File file = new File("c:\\1.txt");
                    PrintWriter pw = new PrintWriter(file);
                    pw.println(true);
                    pw.write(100);
                    pw.close();
                }
            }

15输出语句是char数组

* A: 输出语句是char数组
    * a: 案例代码
    public class Demo {
                public static void main(String[] args) {
                    int[] arr = {1};
                    System.out.println(arr);

                    char[] ch = {'a','b'};
                    System.out.println(ch);

                    byte[] b = {};
                    System.out.println(b);
                }
            }
        * b: 结果分析
            * println数组,只有打印字符数组时只有容,其余均打印数组的地址
                * 因为api中定义了打印字符数组的方法,其底层是在遍历数组中的元素
                * 而其他打印数组的方法,都是将数组对象编程Object,其底层再将对象编程String,调用了String s = String.valueOf(x);方法

16打印流输出目的是String和流对象

* A: 打印流输出目的是String和流对象
    * a: 案例代码
public class PrintWriterDemo {
                public static void main(String[] args) throws  IOException {
                    function_2();

                }

                /*
                 * 打印流,输出目的,是流对象
                 * 可以是字节输出流,可以是字符的输出流
                 * OutputStream  Writer
                 */
                public static void function_2() throws IOException{
                //  FileOutputStream fos = new FileOutputStream("c:\\3.txt");
                    FileWriter fw = new FileWriter("c:\\4.txt");
                    PrintWriter pw = new PrintWriter(fw);
                    pw.println("打印流");
                    pw.close();
                }
                /*
                 * 打印流,输出目的,String文件名
                 */
                public static void function_1() throws FileNotFoundException{
                    PrintWriter pw = new PrintWriter("c:\\2.txt");
                    pw.println(3.5);
                    pw.close();
                }   

            }

17打印流开启自动刷新

* A: 打印流开启自动刷新
    * 案例代码
public class PrintWriterDemo {
                public static void main(String[] args) throws  IOException {
                    function_3();

                }
                /* 
                 * 打印流,可以开启自动刷新功能
                 * 满足2个条件:
                 *   1. 输出的数据目的必须是流对象
                 *       OutputStream  Writer
                 *   2. 必须调用println,printf,format三个方法中的一个,启用自动刷新
                 */
                public static void function_3()throws  IOException{
                    //File f = new File("XXX.txt");
                    FileOutputStream fos = new FileOutputStream("c:\\5.txt");
                    PrintWriter pw = new PrintWriter(fos,true);
                    pw.println("i");
                    pw.println("love");
                    pw.println("java");
                    pw.close();
                }
            }

18打印流复制文本文件

* A: 打印流复制文本文件
    * a: 案例代码
    /*
             * 打印流实现文本复制
             *   读取数据源  BufferedReader+File 读取文本行
             *   写入数据目的 PrintWriter+println 自动刷新
             */
            public class PrintWriterDemo1 {
                public static void main(String[] args) throws IOException{
                    BufferedReader bfr = new BufferedReader(new FileReader("c:\\a.txt"));
                    PrintWriter pw = new PrintWriter(new FileWriter("d:\\a.txt"),true);
                    String line = null;
                    while((line = bfr.readLine())!=null){
                        pw.println(line);
                    }
                    pw.close();
                    bfr.close();
                }
            }

19commons-io工具类介绍

* A: commons-io工具类介绍
    * a: 工具类介绍
        * 解压缩commons-io-2.4.zip文件
        * commons-io-2.4.jar需要导入到项目中的jar包,里面存放的是class文件
        * commons-io-2.4-sources.jar工具类中原代码
        * docs是帮助文档

20使用工具类commons_io

* A: 使用工具类commons_io
    * a: 导入jar包
        * 加入classpath的第三方jar包内的class文件才能在项目中使用
        * 创建lib文件夹
        * 将commons-io.jar拷贝到lib文件夹
        * 右键点击commons-io.jar,Build Path→Add to Build Path
    * b: 学会如何看源代码

21IO工具类FilenameUtils

* A: IO工具类FilenameUtils
    * a: 方法介绍
        * getExtension(String path):获取文件的扩展名;
        * getName():获取文件名;
        * isExtension(String fileName,String ext):判断fileName是否是ext后缀名;
    * b: 案例代码
    public class Commons_IODemo {
                public static void main(String[] args) {
                    function_2();
                }
                /*
                 * FilenameUtils类的方法
                 * static boolean isExtension(String filename,String extension)
                 * 判断文件名的后缀是不是extension
                 */
                public static void function_2(){
                    boolean b = FilenameUtils.isExtension("Demo.java", "java");
                    System.out.println(b);
                }

                /*
                 * FilenameUtils类的方法
                 * static String getName(String filename)
                 * 获取文件名
                 */
                public static void function_1(){
                    String name = FilenameUtils.getName("c:\\windows\\");
                    System.out.println(name);
                }

                /*
                 * FilenameUtils类的方法
                 * static String getExtension(String filename)
                 * 获取文件名的扩展名
                 */
                 public static void function(){
                     String name = FilenameUtils.getExtension("c:\\windows");
                     System.out.println(name);
                 }
            }

22IO工具类FileUtils

* A: IO工具类FileUtils
    * a: 方法介绍
        * readFileToString(File file):读取文件内容,并返回一个String;
        * writeStringToFile(File file,String content):将内容content写入到file中;
        * copyDirectoryToDirectory(File srcDir,File destDir);文件夹复制
        * copyFile(File srcFile,File destFile);文件复制

    * b: 案例代码
    public class Commons_IODemo1 {
                public static void main(String[] args)throws IOException {
                    function_3();
                }
                /*
                 * FileUtils工具类方法
                 * static void copyDirectoryToDirectory(File src,File desc)
                 * 复制文件夹
                 */
                public static void function_3() throws IOException{
                    FileUtils.copyDirectoryToDirectory(new File("d:\\demo"), new File("c:\\"));
                }

                /*
                 * FileUtils工具类的方法
                 * static void copyFile(File src,File desc)
                 * 复制文件
                 */
                public static void function_2() throws IOException{
                    FileUtils.copyFile(new File("c:\\k.jpg"),new File("d:\\k.jpg"));
                }

                /*
                 * FileUtils工具类的方法
                 * static void writeStringToFile(File src,String date)
                 * 将字符串直接写到文件中
                 */
                public static void function_1() throws IOException{
                    FileUtils.writeStringToFile(new File("c:\\b.txt"),"我爱Java编程");
                }

                /*
                 * FileUtils工具类的方法
                 * static String readFileToString(File src)读取文本,返回字符串
                 */
                 public static void function() throws IOException{
                     String s = FileUtils.readFileToString(new File("c:\\a.txt"));
                     System.out.println(s);
                 }
            }

01进程概念

*A:进程概念
*a:进程:进程指正在运行的程序。确切的来说,当一个程序进入内存运行,
即变成一个进程,进程是处于运行过程中的程序,并且具有一定独立功能。

02线程的概念

*A:线程的概念
*a:线程:线程是进程中的一个执行单元(执行路径),负责当前进程中程序的执行,
一个进程中至少有一个线程。一个进程中是可以有多个线程的,
这个应用程序也可以称之为多线程程序。
简而言之:一个程序运行后至少有一个进程,一个进程中可以包含多个线程

03深入线程的概念

A:深入线程的概念
什么是多线程呢?
即就是一个程序中有多个线程在同时执行。
一个核心的CPU在多个线程之间进行着随即切换动作,由于切换时间很短(毫秒甚至是纳秒级别),导致我们感觉不出来

单线程程序:即,若有多个任务只能依次执行。当上一个任务执行结束后,下一个任务开始执行。如去            网吧上网,网吧只能让一个人上网,当这个人下机后,下一个人才能上网。
多线程程序:即,若有多个任务可以同时执行。如,去网吧上网,网吧能够让多个人同时上网。

04迅雷的多线程下载

A:迅雷的多线程下载
多线程,每个线程都读一个文件

05线程的运行模式

A:线程的运行模式
a:分时调度
所有线程轮流使用 CPU 的使用权,平均分配每个线程占用 CPU 的时间。

b:抢占式调度
 优先让优先级高的线程使用 CPU,如果线程的优先级相同,那么会随机选择一个(线程随机性),Java使用的为抢占式调度。

 大部分操作系统都支持多进程并发运行,现在的操作系统几乎都支持同时运行多个程序。比如:现在我们上课一边使用编辑器,一边使用录屏软件,同时还开着画图板,dos窗口等软件。此时,这些程序是在同时运行,”感觉这些软件好像在同一时刻运行着“。

 实际上,CPU(中央处理器)使用抢占式调度模式在多个线程间进行着高速的切换。对于CPU的一个核而言,某个时刻,只能执行一个线程,而 CPU的在多个线程间切换速度相对我们的感觉要快,看上去就是在同一时刻运行。
 其实,多线程程序并不能提高程序的运行速度,但能够提高程序运行效率,让CPU的使用率更高。

06main的主线程

*A:main的主线程
/*
* 程序中的主线程
*/

  public class Demo {
      public static void main(String[] args) {
        System.out.println(0/0);
        function();
        System.out.println(Math.abs(-9));
      }

      public static void function(){
        for(int i = 0 ; i < 10000;i++){
          System.out.println(i);
        }
      }
    }

=======================第二节课开始=============================================

07Thread类介绍

A:Thread类介绍:Thread是程序中的执行线程。Java 虚拟机允许应用程序并发地运行多个执行线程。
发现创建新执行线程有两种方法。
a:一种方法是将类声明为 Thread 的子类。该子类应重写 Thread 类的 run 方法。创建对象,开启线程。run方法相当于其他线程的main方法。
b:另一种方法是声明一个实现 Runnable 接口的类。该类然后实现 run 方法。然后创建Runnable的子类对象,传入到某个线程的构造方法中,开启线程。

08实现线程程序继承Thread

*A:实现线程程序继承Thread

  /*
       * 创建和启动一个线程
       *   创建Thread子类对象
       *   子类对象调用方法start()
       *      让线程程序执行,JVM调用线程中的run
       */
      public class ThreadDemo {
        public static void main(String[] args) {
          SubThread st = new SubThread();
          SubThread st1 = new SubThread();
          st.start();
          st1.start();
          for(int i = 0; i < 50;i++){
            System.out.println("main..."+i);
          }
        }
      }
      /*
       *  定义子类,继承Thread 
       *  重写方法run 
       */
      public class SubThread  extends Thread{
        public void run(){
          for(int i = 0; i < 50;i++){
            System.out.println("run..."+i);
          }
        }
      }

09线程执行的随机性

*A:线程执行的随机性
/*
代码分析:
整个程序就只有三个线程,
一个是主线程
启动另外两个线程

       st.start();
            st1.start();
            for(int i = 0; i < 50;i++){
              System.out.println("main..."+i);
            }
         一个是st(Thread-0)线程
         for(int i = 0; i < 50;i++){
           System.out.println("run..."+i);
         }
         一个是st1(Thread-1)线程下 

    */
     public class ThreadDemo {
       public static void main(String[] args) {
         SubThread st = new SubThread();
         SubThread st1 = new SubThread();
         st.start();
         st1.start();
         for(int i = 0; i < 50;i++){
           System.out.println("main..."+i);
         }
       }
     }
     /*
      *  定义子类,继承Thread 
      *  重写方法run 
      */
     public class SubThread  extends Thread{
       public void run(){
         for(int i = 0; i < 50;i++){
           System.out.println("run..."+i);
         }
       }
     }

10为什么要继承Thread

*A:什么要继承Thread
a:我们为什么要继承Thread类,并调用其的start方法才能开启线程呢?
继承Thread类:因为Thread类用来描述线程,具备线程应该有功能。那为什么不直接创建Thread类的对象呢?
如下代码:
Thread t1 = new Thread();
t1.start();//这样做没有错,但是该start调用的是Thread类中的run方法
//而这个run方法没有做什么事情,更重要的是这个run方法中并没有定义我们需要让线程执行的代码。

b:创建线程的目的是什么?
 是为了建立程序单独的执行路径,让多部分代码实现同时执行。也就是说线程创建并执行需要给定线程要执行的任务。
 对于之前所讲的主线程,它的任务定义在main函数中。自定义线程需要执行的任务都定义在run方法中。

11多线程内存图解

*A:多线程内存图解
多线程执行时,到底在内存中是如何运行的呢?
多线程执行时,在栈内存中,其实每一个执行线程都有一片自己所属的栈内存空间。进行方法的压栈和弹栈。
当执行线程的任务结束了,线程自动在栈内存中释放了。但是当所有的执行线程都结束了,那么进程就结束了。

=======================第三节课开始=============================================

12获取线程名字Thread类方法getName

*A:获取线程名字Thread类方法getName

  /*
     *  获取线程名字,父类Thread方法
     *    String getName()
     */
    public class NameThread extends Thread{

      public NameThread(){
        super("小强");
      }

      public void run(){
        System.out.println(getName());
      }
    }

    /*
     *  每个线程,都有自己的名字
     *  运行方法main线程,名字就是"main"
     *  其他新键的线程也有名字,默认 "Thread-0","Thread-1"
     *  
     *  JVM开启主线程,运行方法main,主线程也是线程,是线程必然就是
     *  Thread类对象
     */
    public class ThreadDemo {
      public static void main(String[] args) {
        NameThread nt = new NameThread();
        nt.start();



      }
    }

13获取线程名字Thread类方法currentThread

*A:获取线程名字Thread类方法currentThread

/*
    *  获取线程名字,父类Thread方法
    *    String getName()
    */
   public class NameThread extends Thread{

     public void run(){
       System.out.println(getName());
     }
   }

   /*
    *  每个线程,都有自己的名字
    *  运行方法main线程,名字就是"main"
    *  其他新键的线程也有名字,默认 "Thread-0","Thread-1"
    *  
    *  JVM开启主线程,运行方法main,主线程也是线程,是线程必然就是
    *  Thread类对象
    *  Thread类中,静态方法
    *   static Thread currentThread()返回正在执行的线程对象
    */
   public class ThreadDemo {
     public static void main(String[] args) {
       NameThread nt = new NameThread();
       nt.start();

       /*Thread t =Thread.currentThread();
       System.out.println(t.getName());*/
       System.out.println(Thread.currentThread().getName());


     }
   }

14线程名字设置

A:线程名字设置

     /*
       *  获取线程名字,父类Thread方法
       *    String getName()
       */
      public class NameThread extends Thread{

        public NameThread(){
          super("小强");
        }

        public void run(){
          System.out.println(getName());
        }
      }

      /*
       *  每个线程,都有自己的名字
       *  运行方法main线程,名字就是"main"
       *  其他新键的线程也有名字,默认 "Thread-0","Thread-1"
       *  
       *  JVM开启主线程,运行方法main,主线程也是线程,是线程必然就是
       *  Thread类对象
       *  Thread类中,静态方法
       *   static Thread currentThread()返回正在执行的线程对象
       */
      public class ThreadDemo {
        public static void main(String[] args) {
          NameThread nt = new NameThread();
          nt.setName("旺财");
          nt.start();

        }
      }

15Thread类方法sleep

A:Thread类方法sleep

    public class ThreadDemo {
      public static void main(String[] args) throws Exception{
        /*for(int i = 0 ; i < 5 ;i++){
          Thread.sleep(50);
          System.out.println(i);
        }*/

        new SleepThread().start();
      }
     }

     public class SleepThread extends Thread{
      public void run(){
        for(int i = 0 ; i < 5 ;i++){
          try{
            Thread.sleep(500);//睡眠500ms,500ms已到并且cpu切换到该线程继续向下执行
          }catch(Exception ex){

          }
          System.out.println(i);
        }
      }
     }

16实现线程的另一种方式实现Runnable接口

A:实现线程的另一种方式实现Runnable接口

   /*
      *  实现接口方式的线程
      *    创建Thread类对象,构造方法中,传递Runnable接口实现类
      *    调用Thread类方法start()
      */
     public class ThreadDemo {
      public static void main(String[] args) {
        SubRunnable sr = new SubRunnable();
        Thread t = new Thread(sr);
        t.start();
        for(int i = 0 ; i < 50; i++){
          System.out.println("main..."+i);
        }
      }
     }

     /*
      *  实现线程成功的另一个方式,接口实现
      *  实现接口Runnable,重写run方法
      */
     public class SubRunnable implements Runnable{
      public void run(){
        for(int i = 0 ; i < 50; i++){
          System.out.println("run..."+i);
        }
      }
     }

17实现接口方式的好处

A:实现接口方式的好处
 第二种方式实现Runnable接口避免了单继承的局限性,所以较为常用。
 实现Runnable接口的方式,更加的符合面向对象,线程分为两部分,一部分线程对象,一部分线程任务。
 继承Thread类,线程对象和线程任务耦合在一起。
 一旦创建Thread类的子类对象,既是线程对象,有又有线程任务。
 实现runnable接口,将线程任务单独分离出来封装成对象,类型就是Runnable接口类型。Runnable接口对线程对象和线程任务进行解耦。
 (降低紧密性或者依赖性,创建线程和执行任务不绑定)

18匿名内部类实现线程程序

*A:匿名内部类实现线程程序 
 /*
     *  使用匿名内部类,实现多线程程序
     *  前提: 继承或者接口实现
     *  new 父类或者接口(){
     *     重写抽象方法
     *  }
     */
    public class ThreadDemo {
      public static void main(String[] args) {
        //继承方式  XXX extends Thread{ public void run(){}}
        new Thread(){
          public void run(){
            System.out.println("!!!");
          }
        }.start();

        //实现接口方式  XXX implements Runnable{ public void run(){}}

        Runnable r = new Runnable(){
          public void run(){
            System.out.println("###");
          }
        };
        new Thread(r).start();


        new Thread(new Runnable(){
          public void run(){
            System.out.println("@@@");
          }
        }).start();

      }
    }

=======================第四节课开始=============================================

19线程的状态图

A:线程的状态图
a:参见线程状态图.jpg

20线程池的原理

A:线程池的原理
1.在java中,如果每个请求到达就创建一个新线程,开销是相当大的。
2.在实际使用中,创建和销毁线程花费的时间和消耗的系统资源都相当大,甚至可能要比在处理实际的用户请求的时间和资源要多的多。
3.除了创建和销毁线程的开销之外,活动的线程也需要消耗系统资源。
如果在一个jvm里创建太多的线程,可能会使系统由于过度消耗内存或“切换过度”而导致系统资源不足。
为了防止资源不足,需要采取一些办法来限制任何给定时刻处理的请求数目,尽可能减少创建和销毁线程的次数,特别是一些资源耗费比较大的线程的创建和销毁,尽量利用已有对象来进行服务。
线程池主要用来解决线程生命周期开销问题和资源不足问题。通过对多个任务重复使用线程,线程创建的开销就被分摊到了多个任务上了,而且由于在请求到达时线程已经存在,所以消除了线程创建所带来的延迟。这样,就可以立即为请求服务,使用应用程序响应更快。另外,通过适当的调整线程中的线程数目可以防止出现资源不足的情况。

21JDK5实现线程池

A:JDK5实现线程池
    /*
       *  JDK1.5新特性,实现线程池程序
       *  使用工厂类 Executors中的静态方法创建线程对象,指定线程的个数
       *   static ExecutorService newFixedThreadPool(int 个数) 返回线程池对象
       *   返回的是ExecutorService接口的实现类 (线程池对象)
       *   
       *   接口实现类对象,调用方法submit (Ruunable r) 提交线程执行任务
       *          
       */
      public class ThreadPoolDemo {
        public static void main(String[] args) {
          //调用工厂类的静态方法,创建线程池对象
          //返回线程池对象,是返回的接口
          ExecutorService es = Executors.newFixedThreadPool(2);
            //调用接口实现类对象es中的方法submit提交线程任务
          //将Runnable接口实现类对象,传递
          es.submit(new ThreadPoolRunnable());
          es.submit(new ThreadPoolRunnable());
          es.submit(new ThreadPoolRunnable());

        }
      }

      public class ThreadPoolRunnable implements Runnable {
        public void run(){
          System.out.println(Thread.currentThread().getName()+" 线程提交任务");
        }
      }

22实现线程的Callable接口方式

A:实现线程的Callable接口方式

     /*
      *  实现线程程序的第三个方式,实现Callable接口方式
      *  实现步骤
      *    工厂类 Executors静态方法newFixedThreadPool方法,创建线程池对象
      *    线程池对象ExecutorService接口实现类,调用方法submit提交线程任务
      *    submit(Callable c)
      */
     public class ThreadPoolDemo1 {
      public static void main(String[] args)throws Exception {
        ExecutorService es = Executors.newFixedThreadPool(2);
        //提交线程任务的方法submit方法返回 Future接口的实现类
        Future<String> f = es.submit(new ThreadPoolCallable());
        String s = f.get();
        System.out.println(s);
      }
     }
     /*
      * Callable 接口的实现类,作为线程提交任务出现
      * 使用方法返回值
      */

     import java.util.concurrent.Callable;

     public class ThreadPoolCallable implements Callable<String>{
      public String call(){
        return "abc";
      }
     }

23线程实现异步计算

A:线程实现异步计算

    /*
     * 使用多线程技术,求和
     * 两个线程,1个线程计算1+100,另一个线程计算1+200的和
     * 多线程的异步计算
     */
    public class ThreadPoolDemo {
      public static void main(String[] args)throws Exception {
        ExecutorService es = Executors.newFixedThreadPool(2);
        Future<Integer> f1 =es.submit(new GetSumCallable(100));
        Future<Integer> f2 =es.submit(new GetSumCallable(200));
        System.out.println(f1.get());
        System.out.println(f2.get());
        es.shutdown();
      }
    }



    public class GetSumCallable implements Callable<Integer>{
      private int a;
      public GetSumCallable(int a){
        this.a=a;
      }

      public Integer call(){
        int sum = 0 ;
        for(int i = 1 ; i <=a ; i++){
          sum = sum + i ;
        }
        return sum;
      }
    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值