load.java~6~

来自「该系统是一个文件配置与检索的系统,该文件主要是关于该系统的一些测试文档等.」· JAVA~6~ 代码 · 共 95 行

JAVA~6~
95
字号
package test;

import java.io.File;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.util.List;
import java.util.Iterator;
import java.io.FileReader;
import java.io.BufferedReader;
import java.util.ArrayList;
public class Load {
    String path;//文件的路径
    String[] all;
    List l;
    File file;
    BufferedReader br;
    String[] content;
    String temp;

    public Load(String path){
        this.path = path;
        try {

            l = new ArrayList();
            file = new File("C:/d.txt");
            br = new BufferedReader(new FileReader(file));
        } catch (Exception e) {

        }

    }
    public void getContent(){
        File file = new File(path);
    }
    public String[] allContent(){//导入文件中的所有内容

        return all;
    }

}
/*package rc;

import java.io.*;
import java.util.*;
public class Load {
    List l;
    File file;
    BufferedReader br;
    String[] content;
    String temp;
    public Load(){
        try{

            l = new ArrayList();
            file = new File("C:/d.txt");
            br = new BufferedReader(new FileReader(file));
        }
        catch(Exception e){

        }
    }
    public String[] contents(){
        try {
            while ((temp = br.readLine()) != null) {
                l.add(temp);
            }
        }
        catch (Exception e) {
        }
        String[] re = new String[l.size()];
        Iterator it = l.iterator();
        int i = 0;
        while(it.hasNext()){
            re[i++] = ((String)it.next()).trim();
        }
        return re;
    }
    public static void main(String args[]){
        Load l = new Load();
        String[] all = l.contents();
        for(int i = 0; i < all.length; i++){
            System.out.println("第 "+ i + " 个 : 是 " + all[i]);
        }
        System.out.println("length:"+all[0].length());
        String s1 = all[0];
        for(int i = 1; i < all.length; i++){
            if(all[i].startsWith("-a ")){
                System.out.println("-a : have these : --> " + all[i].substring(3));
            }
        }
    }

}
*/

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?