JavaSE_按行读取文件

来源:互联网 发布:苏州 矩阵光电 新三板 编辑:程序博客网 时间:2024/06/07 02:51

主要函数:

public static void readFileAndSendRequest(String host, String filePath){File file = new File(filePath);BufferedReader reader = null;try {reader = new BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8"));String href = null;String log = null;String suffix = null;while ((log = reader.readLine()) != null) {//track-logString[] arguments = log.split(" - ");//System.out.println(arguments.length);String trackArgument = arguments[3].trim().replaceAll("\"", "");//System.out.println(trackArgument);String[] track_args = trackArgument.split(" ");//System.out.println(track_args[1]);//if(!track_args[1].contains("/track_proxy")){//continue;//}suffix = track_args[1];href = host+suffix;String result = SendRequestToCollectServer.requestUrl(href);//TODO :Remove ???System.out.println(result);}} catch (IOException e) {throw new RuntimeException(e);} finally {try {if (null != reader) {reader.close();}} catch (IOException e) {e.printStackTrace();}}}



0 0
原创粉丝点击