1.用java读取txt文件

    public static String readFJ(String path) { 
        path = "D:/workspace/hetong.txt"; 
        File file = new File(path); 
        StringBuffer txt= new StringBuffer(); 
        if(file.isFile() && file.exists()) { 
            //InputStreamReader in = null; 
            try { 
                InputStreamReader in = new InputStreamReader(new FileInputStream(file),"GBK"); 
                BufferedReader bfd = new BufferedReader(in); 
                String s; 
                while((s=bfd.readLine())!=null) { 
                    txt.append(s); 
                } 
                in.close(); 
                bfd.close(); 
            } catch (IOException e) { 
                // TODO Auto-generated catch block 
                e.printStackTrace(); 
            } 
        } 
        return txt.toString(); 
    }

2.用selenium读取txt文件

    public static String readFS(String path) { 
        File file = new File(path); 
        String s = null; 
        try { 
            s = FileHandler.readAsString(file); 
        } catch (IOException e) { 
            // TODO Auto-generated catch block 
            e.printStackTrace(); 
        } 
        return s; 
    }

发布评论
IT源码网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

jmeter压测中实现登录接口只调用一次讲解
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。