小编sud*_*ong的帖子

快速CSV解析

我有一个java服务器应用程序,下载CSV文件并解析它.解析可能需要5到45分钟,并且每小时发生一次.这种方法是应用程序的瓶颈,因此它不是过早的优化.到目前为止的代码:

        client.executeMethod(method);
        InputStream in = method.getResponseBodyAsStream(); // this is http stream

        String line;
        String[] record;

        reader = new BufferedReader(new InputStreamReader(in), 65536);

        try {
            // read the header line
            line = reader.readLine();
            // some code
            while ((line = reader.readLine()) != null) {
                 // more code

                 line = line.replaceAll("\"\"", "\"NULL\"");

                 // Now remove all of the quotes
                 line = line.replaceAll("\"", "");     


                 if (!line.startsWith("ERROR"){
                   //bla bla 
                    continue;
                 }

                 record = line.split(",");
                 //more error handling
                 // build the object and put it in HashMap …
Run Code Online (Sandbox Code Playgroud)

java csv parsing

15
推荐指数
4
解决办法
2万
查看次数

什么是单身人士,用简单的英语?

我现在一直在谷歌搜索大约一小时,我仍然不清楚单身是什么.任何人都可以让我更清楚,也许发布一个代码示例?

我只知道你是否只能拥有一个给定类的一个实例.但是你不能只用那个静态类吗?

提前致谢!

java singleton design-patterns

2
推荐指数
1
解决办法
409
查看次数

标签 统计

java ×2

csv ×1

design-patterns ×1

parsing ×1

singleton ×1