码迷,mamicode.com
首页 > 其他好文 > 详细

selenium读取txt文件的几种方式

时间:2015-06-09 19:29:52      阅读:1221      评论:0      收藏:0      [点我收藏+]

标签:

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;
    }

 

selenium读取txt文件的几种方式

标签:

原文地址:http://www.cnblogs.com/qiaoyeye/p/4564272.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!