Package com.utils

Examples of com.utils.BigFile$FileIterator


            try {
                Statement stat = conn_stats.createStatement();
                String f_name = new File(dir + "/" + u.substring(u.lastIndexOf("/"), u.length())).toString();
                debug("(3) - start import: " + f_name);
                BigFile lines = new BigFile(f_name);
                //List<String> lines = (List<String>) org.apache.commons.io.FileUtils.readLines(new File(f_name), "UTF-8");

                int n = 0;
                for (String l : lines) {
                    String fields[] = l.split(",");
View Full Code Here


            com.utils.HttpUtil.downloadData(url, f);
            com.utils.IOUtil.unzip(f, f.replace(".gz", ""));

            File file_to_read = new File(f.replaceAll(".gz", ""));

            BigFile lines = null;

            try {
                lines = new BigFile(file_to_read.toString());
            } catch (Exception e) {
                fatal("Excpetion", e);
                return;
            }

            try {

                Statement stat = conn_url.createStatement();
                stat.executeUpdate(properties.get("query_delete"));
                stat.close();
            } catch (SQLException e) {
                fatal("SQLException", e);

            }


            try {
                conn_url.setAutoCommit(false);
            } catch (SQLException e) {
                fatal("SQLException", e);
            }


            boolean ok = true;
            int i = 0;
            for (String line : lines) {
                if (StringUtil.isEmpty(line) || line.indexOf(" ") == -1) {
                    continue;
                }
                //eseguo la insert
                try {
                    line = line.substring(line.indexOf(" "));
                    line = line.trim();
                    if (getIPException(line)) {
                        continue;
                    }
                    Statement stat = this.conn_url.createStatement();
                    stat.executeUpdate("insert into blacklist(url) values('" + line + "')");
                    stat.close();
                    i++;
                } catch (SQLException e) {
                    fatal("SQLException", e);
                    try {
                        conn_url.rollback();
                    } catch (SQLException ex) {
                        fatal("SQLException", ex);
                    }
                    ok = false;
                    break;
                }


            }


            //elimino il file originale per risparmiare spazio su disco
            boolean del = file_to_read.delete();
            debug("File " + file_to_read + " del:" + del);





            //altro file da scaricare...



            //scarico il file
            name = "spam-ip.com_" + DateTimeUtil.getNowWithFormat("MM-dd-yyyy") + ".csv";
            f = this.path_app_root + "/" + this.properties.get("dir") + "/";
            org.apache.commons.io.FileUtils.forceMkdir(new File(f));
            f += "/" + name;
            url = "http://spam-ip.com/csv_dump/" + name;

            debug("(2) - start download: " + url);
            com.utils.HttpUtil.downloadData(url, f);

            file_to_read = new File(f);
            try {
                lines = new BigFile(file_to_read.toString());
            } catch (Exception e) {
                fatal("Exception", e);
                return;
            }
View Full Code Here

TOP

Related Classes of com.utils.BigFile$FileIterator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.