Example usage for java.util Vector clear

List of usage examples for java.util Vector clear

Introduction

In this page you can find the example usage for java.util Vector clear.

Prototype

public void clear() 

Source Link

Document

Removes all of the elements from this Vector.

Usage

From source file:de.blinkt.openvpn.core.ConfigParser.java

private void checkinlinefile(Vector<String> args, BufferedReader br) throws IOException, ConfigParseError {
    String arg0 = args.get(0).trim();
    // CHeck for <foo>
    if (arg0.startsWith("<") && arg0.endsWith(">")) {
        String argname = arg0.substring(1, arg0.length() - 1);
        String inlinefile = VpnProfile.INLINE_TAG;

        String endtag = String.format("</%s>", argname);
        do {/* w  w  w .  j av a2s.  c  o  m*/
            String line = br.readLine();
            if (line == null) {
                throw new ConfigParseError(
                        String.format("No endtag </%s> for starttag <%s> found", argname, argname));
            }
            if (line.trim().equals(endtag))
                break;
            else {
                inlinefile += line;
                inlinefile += "\n";
            }
        } while (true);

        if (inlinefile.endsWith("\n"))
            inlinefile = inlinefile.substring(0, inlinefile.length() - 1);

        args.clear();
        args.add(argname);
        args.add(inlinefile);
    }

}

From source file:edu.ku.brc.af.tasks.subpane.formeditor.ViewSetSelectorPanel.java

protected void viewSetSelected() {
    selectedViewSet = null;/* w w w.  jav a2  s .co  m*/
    selectedView = null;
    selectedViewDef = null;
    selectedAltView = null;

    ((DefaultTreeModel) tree.getModel()).setRoot(null);

    DefaultListModel model;

    model = (DefaultListModel) altViewsList.getModel();
    model.clear();

    model = (DefaultListModel) viewDefsList.getModel();
    model.clear();

    model = (DefaultListModel) viewsList.getModel();
    model.clear();

    int inx = viewSetsList.getSelectedIndex();
    if (inx > -1) {
        selectedViewSet = (ViewSet) viewSetVector.get(inx);

        viewControlPanel.getAddBtn().setEnabled(true);
        viewDefControlPanel.getAddBtn().setEnabled(true);

        Vector<String> names = new Vector<String>(selectedViewSet.getViews().keySet());
        Collections.sort(names);
        for (String viewName : names) {
            model.addElement(viewName);
        }

        model = (DefaultListModel) viewDefsList.getModel();
        names.clear();
        names.addAll(selectedViewSet.getViewDefs().keySet());
        Collections.sort(names);
        for (String viewDefName : names) {
            model.addElement(viewDefName);
        }

    } else {
        viewControlPanel.getAddBtn().setEnabled(false);
        viewDefControlPanel.getAddBtn().setEnabled(false);
    }
}

From source file:edu.ku.brc.specify.tools.StrLocalizerApp.java

/**
 * @param src//from   w  w  w.  ja  v a  2 s. c  o m
 * @param dst
 */
private void mergeToDst(final StrLocaleFile src, final StrLocaleFile dst) {
    Hashtable<String, StrLocaleEntry> dstHash = dst.getItemHash();

    Vector<StrLocaleEntry> srcItems = src.getItems();
    Vector<StrLocaleEntry> dstItems = dst.getItems();

    dstItems.clear();

    for (StrLocaleEntry srcEntry : srcItems) {
        String key = srcEntry.getKey();
        if (key == null || key.equals("#")) {
            dstItems.add(srcEntry);
        } else {
            StrLocaleEntry dstEntry = dstHash.get(key);
            if (dstEntry != null) {
                dstEntry.setDstStr(srcEntry.getDstStr());
                //dstEntry.setSrcStr(srcEntry.getDstStr());
                dstItems.add(dstEntry);
            } else {
                dstItems.add(srcEntry);
            }
        }
    }
}

From source file:edu.umn.cs.spatialHadoop.core.RTree.java

/**
 * k nearest neighbor query/*  w w w  . j  av a 2 s. co  m*/
 * @param qx
 * @param qy
 * @param k
 * @param output
 */
public int knn(final double qx, final double qy, int k, final ResultCollector2<T, Double> output) {
    double query_area = ((getMBR().x2 - getMBR().x1) * (getMBR().y2 - getMBR().y1)) * k / getElementCount();
    double query_radius = Math.sqrt(query_area / Math.PI);

    boolean result_correct;
    final Vector<Double> distances = new Vector<Double>();
    final Vector<T> shapes = new Vector<T>();
    // Find results in the range and increase this range if needed to ensure
    // correctness of the answer
    do {
        // Initialize result and query range
        distances.clear();
        shapes.clear();
        Rectangle queryRange = new Rectangle();
        queryRange.x1 = qx - query_radius;
        queryRange.y1 = qy - query_radius;
        queryRange.x2 = qx + query_radius;
        queryRange.y2 = qy + query_radius;
        // Retrieve all results in range
        search(queryRange, new ResultCollector<T>() {
            @Override
            public void collect(T shape) {
                distances.add(shape.distanceTo(qx, qy));
                shapes.add((T) shape.clone());
            }
        });
        if (shapes.size() < k) {
            // Didn't find k elements in range, double the range to get more items
            if (shapes.size() == getElementCount()) {
                // Already returned all possible elements
                result_correct = true;
            } else {
                query_radius *= 2;
                result_correct = false;
            }
        } else {
            // Sort items by distance to get the kth neighbor
            IndexedSortable s = new IndexedSortable() {
                @Override
                public void swap(int i, int j) {
                    double temp_distance = distances.elementAt(i);
                    distances.set(i, distances.elementAt(j));
                    distances.set(j, temp_distance);

                    T temp_shape = shapes.elementAt(i);
                    shapes.set(i, shapes.elementAt(j));
                    shapes.set(j, temp_shape);
                }

                @Override
                public int compare(int i, int j) {
                    // Note. Equality is not important to check because items with the
                    // same distance can be ordered anyway. 
                    if (distances.elementAt(i) == distances.elementAt(j))
                        return 0;
                    if (distances.elementAt(i) < distances.elementAt(j))
                        return -1;
                    return 1;
                }
            };
            IndexedSorter sorter = new QuickSort();
            sorter.sort(s, 0, shapes.size());
            if (distances.elementAt(k - 1) > query_radius) {
                result_correct = false;
                query_radius = distances.elementAt(k);
            } else {
                result_correct = true;
            }
        }
    } while (!result_correct);

    int result_size = Math.min(k, shapes.size());
    if (output != null) {
        for (int i = 0; i < result_size; i++) {
            output.collect(shapes.elementAt(i), distances.elementAt(i));
        }
    }
    return result_size;
}

From source file:playground.meisterk.org.matsim.run.facilities.ShopsOf2005ToFacilities.java

private static void processMigrosZHOpenTimes(final ActivityFacilitiesImpl facilities) {

    System.out.println("Setting up Migros ZH open times...");

    List<String> lines = null;
    String[] tokens = null;//from   w w w  .  java 2s.  c o m
    String[] openHourTokens = null;
    String[] openDayTokens = null;
    Vector<Integer> numbers = new Vector<Integer>();

    try {

        lines = FileUtils.readLines(new File(migrosZHFilename), "UTF-8");

    } catch (IOException e) {
        e.printStackTrace();
    }

    for (String line : lines) {

        //System.out.println(line);
        tokens = line.split(FIELD_DELIM);

        // ignore header line
        if (tokens[0].equals("KST")) {
            continue;
        }

        shopId = new ShopId(MIGROS, "", tokens[1], MIGROS_ZH, tokens[3].split(" ")[0], tokens[3].split(" ")[1],
                tokens[2]);
        String facilityId = shopId.getShopId();
        System.out.println(facilityId);
        System.out.flush();

        ActivityFacility theCurrentMigrosZH = facilities.getFacilities()
                .get(Id.create(facilityId, ActivityFacility.class));
        if (theCurrentMigrosZH != null) {
            ActivityOptionImpl shopping = ((ActivityFacilityImpl) theCurrentMigrosZH)
                    .createActivityOption(ACTIVITY_TYPE_SHOP);
            String openTimeString = tokens[6];
            openHourTokens = openTimeString.split(ANYTHING_BUT_DIGITS);
            openDayTokens = openTimeString.split(ANYTHING_BUT_LETTERS);
            numbers.clear();
            // print open time strings
            for (String token : openDayTokens) {
                if (token.equals("")) {

                } else {
                    System.out.print(token + "\t");
                }
            }
            System.out.println();
            for (String token : openHourTokens) {
                if (token.equals("")) {

                } else {
                    System.out.print(token + "\t");
                }
            }
            System.out.println();
            System.out.flush();

            // process numbers
            int openDayTokenPointer = 1;
            double time = 0;
            double oldTime = 0;
            boolean isHour = true;
            boolean isOpen = true;
            OpeningTimeImpl opentime = null;
            Day[] days = Day.values();

            for (String openHourToken : openHourTokens) {
                if (!openHourToken.equals("")) {
                    if (isHour) {
                        time = Integer.parseInt(openHourToken) * 3600;
                    } else {

                        time += Integer.parseInt(openHourToken) * 60;

                        //                     System.out.println(Time.writeTime(time));

                        if (isOpen) {

                            System.out.println("Open: " + Time.writeTime(time));

                            //                        // check if we have to go to the next day
                            if (time < oldTime) {

                                openDayTokenPointer++;
                                while (openDayTokens[openDayTokenPointer].equals("Ausn")
                                        || openDayTokens[openDayTokenPointer].equals("")) {
                                    openDayTokenPointer++;
                                }

                            }

                        } else {

                            System.out.println("Close: " + Time.writeTime(time));

                            Day day = Day.getDayByGermanAbbrev(openDayTokens[openDayTokenPointer]);

                            switch (day) {
                            case FRIDAY:
                                System.out.println("Adding times to weekdays...");
                                for (int weekday = 0; weekday <= 4; weekday++) {
                                    opentime = new OpeningTimeImpl(days[weekday].getAbbrevEnglish(), oldTime,
                                            time);
                                    shopping.addOpeningTime(opentime);
                                }
                                break;
                            default:
                                DayType englishDayString = day.getAbbrevEnglish();
                                System.out.println("Adding times to " + englishDayString + "...");
                                opentime = new OpeningTimeImpl(englishDayString, oldTime, time);
                                shopping.addOpeningTime(opentime);
                                break;
                            }
                        }

                        isOpen = !isOpen;

                        oldTime = time;

                    }

                    isHour = !isHour;

                }

            }
        }

    }

    System.out.println("Setting up Migros ZH open times...done.");

}

From source file:edu.ku.brc.specify.tasks.RecordSetTask.java

@SuppressWarnings("unchecked")
protected void processDeleteRSItems(final CommandAction cmd) {
    Object data = cmd.getData();// w  w w .  j a  v a  2 s .c o  m
    if (data instanceof Object[]) {
        RecordSetIFace rs = (RecordSetIFace) ((Object[]) data)[0];
        List<Integer> ids = (List<Integer>) ((Object[]) data)[1];

        if (rs instanceof RecordSetProxy) {
            RecordSetProxy recordSet = (RecordSetProxy) rs;

            deleteItems(recordSet.getRecordSetId(), ids, null);

        } else if (rs instanceof RecordSet) {
            RecordSet recordSet = (RecordSet) rs;
            if (recordSet.getRecordSetId() == null) {
                for (RecordSetItem rsi : new Vector<RecordSetItem>(recordSet.getRecordSetItems())) {
                    recordSet.getRecordSetItems().remove(rsi);
                }

            } else {
                // TODO Add StaleObject Code from FormView
                DataProviderSessionIFace session = DataProviderFactory.getInstance().createSession();
                try {
                    FormHelper.updateLastEdittedInfo(recordSet);

                    session.beginTransaction();

                    Vector<RecordSetItemIFace> items = new Vector<RecordSetItemIFace>(
                            recordSet.getOrderedItems());
                    for (Integer id : ids) {
                        for (RecordSetItemIFace rsi : items) {
                            if (rsi.getRecordId().intValue() == id.intValue()) {
                                //System.out.println(recordSet.getItems().contains(rsi));
                                recordSet.removeItem(rsi);
                                session.delete(rsi);
                                //System.out.println(recordSet.getItems().contains(rsi));
                            }
                        }
                    }

                    items.clear();
                    session.saveOrUpdate(recordSet);
                    session.commit();
                    session.flush();

                } catch (Exception ex) {
                    edu.ku.brc.af.core.UsageTracker.incrHandledUsageCount();
                    edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(RecordSetTask.class, ex);
                    ex.printStackTrace();
                    //log.error(ex);

                } finally {
                    session.close();
                }

            }
        }
    }
}

From source file:org.openmrs.web.dwr.DWRPersonService.java

/**
 * Find Person objects based on the given searchPhrase
 *
 * @param searchPhrase partial name or partial identifier
 * @param includeRetired true/false whether to include the voided objects
 * @param roles if not null, restricts search to only users and only users with these roles
 * @param start the beginning index (this is only used for user search i.e of roles are
 *            specified)/*from   w w w .  jav  a2s. c  o m*/
 * @param length the number of matching people to return (this is only used for user search i.e
 *            of roles are specified)
 * @return list of persons that match the given searchPhrase. The PersonListItems
 * @since 1.8
 */
public Vector<Object> findBatchOfPeopleByRoles(String searchPhrase, boolean includeRetired, String roles,
        Integer start, Integer length) {
    Vector<Object> personList = new Vector<Object>();
    try {
        Boolean includeVoided = includeRetired;
        // if roles were given, search for users with those roles
        if (StringUtils.isNotBlank(roles)) {
            UserService us = Context.getUserService();

            List<Role> roleList = new Vector<Role>();
            roles = roles.trim();

            String[] splitRoles = roles.split(",");
            for (String role : splitRoles) {
                roleList.add(new Role(role));
            }

            for (User u : us.getUsers(searchPhrase, roleList, includeRetired, start, length)) {
                personList.add(new UserListItem(u));
            }

        } else {
            //TODO add batch person look up to the API and use it here and FIX the javadocs
            // if no roles were given, search for normal people
            PersonService ps = Context.getPersonService();
            for (Person p : ps.getPeople(searchPhrase, null, includeVoided)) {
                personList.add(PersonListItem.createBestMatch(p));
            }

            // also search on patient identifier if the query contains a number
            if (searchPhrase.matches(".*\\d+.*")) {
                PatientService patientService = Context.getPatientService();
                for (Patient p : patientService.getPatients(searchPhrase, null, null, false)) {
                    personList.add(PersonListItem.createBestMatch(p));
                }
            }

        }
    } catch (Exception e) {
        log.error("Error while searching for persons", e);
        personList.clear();
        personList.add(
                Context.getMessageSourceService().getMessage("Person.search.error") + " - " + e.getMessage());
    }
    return personList;
}

From source file:com.ricemap.spateDB.core.RTree.java

/**
 * k nearest neighbor query Note: Current algorithm is approximate just for
 * simplicity. Writing an exact algorithm is on our TODO list
 * /*from w  w w . j a  va  2s  .c  o m*/
 * @param qx
 * @param qy
 * @param k
 * @param output
 */
public int knn(final double qt, final double qx, final double qy, int k,
        final ResultCollector2<T, Double> output) {
    double query_area = ((getMBR().x2 - getMBR().x1) * (getMBR().y2 - getMBR().y1)) * k / getElementCount();
    double query_radius = Math.sqrt(query_area / Math.PI);

    boolean result_correct;
    final Vector<Double> distances = new Vector<Double>();
    final Vector<T> shapes = new Vector<T>();
    // Find results in the range and increase this range if needed to ensure
    // correctness of the answer
    do {
        // Initialize result and query range
        distances.clear();
        shapes.clear();
        Prism queryRange = new Prism();
        queryRange.x1 = qx - query_radius / 2;
        queryRange.y1 = qy - query_radius / 2;
        queryRange.x2 = qx + query_radius / 2;
        queryRange.y2 = qy + query_radius / 2;
        // Retrieve all results in range
        searchColumnar(queryRange, new ResultCollector<Writable>() {
            @Override
            public void collect(Writable shape) {
                distances.add(((T) shape).distanceTo(qt, qx, qy));
                shapes.add((T) ((T) shape).clone());
            }
        }, null);
        if (shapes.size() < k) {
            // Didn't find k elements in range, double the range to get more
            // items
            if (shapes.size() == getElementCount()) {
                // Already returned all possible elements
                result_correct = true;
            } else {
                query_radius *= 2;
                result_correct = false;
            }
        } else {
            // Sort items by distance to get the kth neighbor
            IndexedSortable s = new IndexedSortable() {
                @Override
                public void swap(int i, int j) {
                    double temp_distance = distances.elementAt(i);
                    distances.set(i, distances.elementAt(j));
                    distances.set(j, temp_distance);

                    T temp_shape = shapes.elementAt(i);
                    shapes.set(i, shapes.elementAt(j));
                    shapes.set(j, temp_shape);
                }

                @Override
                public int compare(int i, int j) {
                    // Note. Equality is not important to check because
                    // items with the
                    // same distance can be ordered anyway.
                    if (distances.elementAt(i) < distances.elementAt(j))
                        return -1;
                    return 1;
                }
            };
            IndexedSorter sorter = new QuickSort();
            sorter.sort(s, 0, shapes.size());
            if (distances.elementAt(k - 1) > query_radius) {
                result_correct = false;
                query_radius = distances.elementAt(k);
            } else {
                result_correct = true;
            }
        }
    } while (!result_correct);

    int result_size = Math.min(k, shapes.size());
    if (output != null) {
        for (int i = 0; i < result_size; i++) {
            output.collect(shapes.elementAt(i), distances.elementAt(i));
        }
    }
    return result_size;
}

From source file:edu.ku.brc.specify.toycode.mexconabio.AnalysisWithGBIFToGBIF.java

@Override
public void process(final int type, final int options) {
    calcMaxScore();/*from   w ww . j av a  2  s.c o  m*/

    String gbifSQL = "SELECT DISTINCT id, catalogue_number, genus, species, subspecies, latitude, longitude, country, state_province, collector_name, locality, year, month, day, collector_num ";

    String fromClause1a = "FROM raw WHERE collector_num LIKE ? AND year = ? AND genus = ?";
    String fromClause1b = "FROM raw WHERE collector_num IS NULL AND year = ? AND genus = ?";
    //String fromClause2  = "FROM raw WHERE collector_num IS NULL AND year = ? AND month = ? AND genus = ? AND id <> ?";

    //                        1       2           3        4           5         6          7         8           9               10          11       12    13    14      15
    String postSQL = "FROM raw WHERE collector_num IS NOT NULL GROUP BY collector_num, year, genus";
    String srcSQL = "SELECT id, catalogue_number, genus, species, subspecies, latitude, longitude, country, state_province, collector_name, locality, year, month, day, collector_num "
            + postSQL + " ORDER BY collector_num";

    String grphashSQL = "SELECT name FROM group_hash";

    String gbifgbifInsert = "INSERT INTO gbifgbif (reltype, score, GBIFID, SNIBID) VALUES (?,?,?,?)";

    Statement stmt = null;
    PreparedStatement gStmt1a = null;
    PreparedStatement gStmt1b = null;
    //PreparedStatement gStmt2  = null;
    PreparedStatement gsStmt = null;

    Object[] refRow = new Object[NUM_FIELDS];
    Object[] cmpRow = new Object[NUM_FIELDS];

    long totalRecs = BasicSQLUtils.getCount(dbSrcConn, "SELECT COUNT(*) FROM group_hash");
    long procRecs = 0;
    long startTime = System.currentTimeMillis();
    int secsThreshold = 0;

    String blank = "X?";

    PrintWriter pw = null;
    try {
        pw = new PrintWriter("scoring_gbifgbif.log");

        gStmt1a = dbGBIFConn.prepareStatement(gbifSQL + fromClause1a);
        gStmt1b = dbGBIFConn.prepareStatement(gbifSQL + fromClause1b);

        //gStmt2 = dbGBIFConn.prepareStatement(gbifSQL + fromClause2);
        gsStmt = dbDstConn.prepareStatement(gbifgbifInsert);

        stmt = dbSrcConn.createStatement(ResultSet.FETCH_FORWARD, ResultSet.CONCUR_READ_ONLY);
        stmt.setFetchSize(Integer.MIN_VALUE);

        System.out.println("Starting Query... " + totalRecs);
        pw.println("Starting Query... " + totalRecs);
        System.out.flush();
        pw.flush();

        HashSet<Integer> idHash = new HashSet<Integer>();
        int writeCnt = 0;
        ResultSet rs = stmt.executeQuery(grphashSQL);

        System.out
                .println(String.format("Starting Processing... Total Records %d  Max Score: %d  Threshold: %d",
                        totalRecs, maxScore, thresholdScore));
        pw.println(String.format("Starting Processing... Total Records %d  Max Score: %d  Threshold: %d",
                totalRecs, maxScore, thresholdScore));
        System.out.flush();
        pw.flush();

        Vector<Object[]> group = new Vector<Object[]>();
        ArrayList<Integer> ids = new ArrayList<Integer>();
        while (rs.next()) {
            String[] tokens = StringUtils.split(rs.getString(1), '_');

            String colNum = tokens[0].trim();
            String year = tokens[1].trim();
            String genus = tokens[2].trim();

            if (StringUtils.isEmpty(colNum) || colNum.equals(blank))
                colNum = null;
            if (StringUtils.isEmpty(year) || year.equals(blank))
                year = null;
            if (StringUtils.isEmpty(genus) || genus.equals(blank))
                genus = null;

            PreparedStatement gStmt1;
            if (colNum != null) {
                gStmt1 = gStmt1a;
                gStmt1.setString(1, "%" + colNum + "%");
            } else {
                gStmt1 = gStmt1b;
                gStmt1.setString(1, null);
            }
            gStmt1.setString(2, year);
            gStmt1.setString(3, genus);
            ResultSet gRS = gStmt1.executeQuery();

            ids.clear();
            int maxNonNullTot = -1;
            int maxNonNullInx = -1;
            int inx = 0;
            while (gRS.next()) {

                Object[] row = getRow();
                int cnt = fillRowWithScore(row, gRS);
                if (cnt > maxNonNullTot) {
                    maxNonNullInx = inx;
                    maxNonNullTot = cnt;
                }
                group.add(row);
                ids.add(gRS.getInt(1));
                inx++;
            }
            gRS.close();

            if (inx < 2) {
                for (Object[] r : group) {
                    recycleRow(r);
                }
                group.clear();
                continue;
            }

            System.arraycopy(group.get(maxNonNullInx), 0, refRow, 0, refRow.length);

            Integer srcId = ids.get(maxNonNullInx);

            for (int i = 0; i < group.size(); i++) {
                if (i != maxNonNullInx) {
                    int score = score(refRow, group.get(i));

                    if (score > thresholdScore) {
                        writeCnt++;

                        int gbifID = ids.get(i);
                        gsStmt.setInt(1, 1); // reltype
                        gsStmt.setInt(2, score); // score
                        gsStmt.setInt(3, gbifID);
                        gsStmt.setInt(4, srcId);
                        gsStmt.executeUpdate();

                        idHash.add(gbifID);
                    }
                }
            }

            idHash.clear();

            for (Object[] r : group) {
                recycleRow(r);
            }
            group.clear();

            if (gStmt1 == gStmt1b) {
                continue;
            }

            gStmt1 = gStmt1b;
            gStmt1.setString(1, year);
            gStmt1.setString(2, genus);

            gRS = gStmt1.executeQuery();
            while (gRS.next()) {
                fillRowWithScore(cmpRow, gRS);

                int gbifID = gRS.getInt(1);
                if (gbifID == srcId)
                    continue;

                int score = score(refRow, cmpRow);

                if (score > thresholdScore) {
                    writeCnt++;
                    gsStmt.setInt(1, 1); // reltype
                    gsStmt.setInt(2, score); // score
                    gsStmt.setInt(3, gbifID);
                    gsStmt.setInt(4, srcId);
                    gsStmt.executeUpdate();
                }
            }
            gRS.close();

            procRecs++;
            if (procRecs % 500 == 0) {
                long endTime = System.currentTimeMillis();
                long elapsedTime = endTime - startTime;

                double timePerRecord = (elapsedTime / procRecs);

                double hrsLeft = ((totalRecs - procRecs) * timePerRecord) / HRS;

                int seconds = (int) (elapsedTime / 60000.0);
                if (secsThreshold != seconds) {
                    secsThreshold = seconds;

                    String msg = String.format("Elapsed %8.2f hr.mn   Percent: %6.3f  Hours Left: %8.2f ",
                            ((double) (elapsedTime)) / HRS, 100.0 * ((double) procRecs / (double) totalRecs),
                            hrsLeft);
                    System.out.println(msg);
                    pw.println(msg);
                    pw.flush();
                }
            }
        }
        rs.close();

        System.out.println("Done.");
        pw.println("Done.");

    } catch (Exception ex) {
        ex.printStackTrace();
    } finally {
        try {
            if (stmt != null) {
                stmt.close();
            }
            if (gStmt1a != null) {
                gStmt1a.close();
            }
            if (gStmt1b != null) {
                gStmt1b.close();
            }
            /*if (gStmt2 != null)
            {
            gStmt2.close();
            }*/
        } catch (Exception ex) {

        }
    }
    System.out.println("Done.");
    pw.println("Done.");
    pw.flush();
    pw.close();
}

From source file:com.apache.fastandroid.novel.view.readview.PageFactory.java

/**
 * ?????/*from w w w  .ja v a 2 s  .  c o m*/
 *
 * @return
 */
public Vector<String> pageLast() {
    String strParagraph = "";
    Vector<String> lines = new Vector<>();
    currentPage = 0;
    while (curEndPos < mbBufferLen) {
        int paraSpace = 0;
        mPageLineCount = mVisibleHeight / (mFontSize + mLineSpace);
        curBeginPos = curEndPos;
        while ((lines.size() < mPageLineCount) && (curEndPos < mbBufferLen)) {
            byte[] parabuffer = readParagraphForward(curEndPos);
            curEndPos += parabuffer.length;
            try {
                strParagraph = new String(parabuffer, charset);
            } catch (UnsupportedEncodingException e) {
                e.printStackTrace();
            }
            strParagraph = strParagraph.replaceAll("\r\n", "  ");
            strParagraph = strParagraph.replaceAll("\n", " "); // ????

            while (strParagraph.length() > 0) {
                int paintSize = mPaint.breakText(strParagraph, true, mVisibleWidth, null);
                lines.add(strParagraph.substring(0, paintSize));
                strParagraph = strParagraph.substring(paintSize);
                if (lines.size() >= mPageLineCount) {
                    break;
                }
            }
            lines.set(lines.size() - 1, lines.get(lines.size() - 1) + "@");

            if (strParagraph.length() != 0) {
                try {
                    curEndPos -= (strParagraph).getBytes(charset).length;
                } catch (UnsupportedEncodingException e) {
                    e.printStackTrace();
                }
            }
            paraSpace += mLineSpace;
            mPageLineCount = (mVisibleHeight - paraSpace) / (mFontSize + mLineSpace);
        }
        if (curEndPos < mbBufferLen) {
            lines.clear();
        }
        currentPage++;
    }
    //SettingManager.getInstance().saveReadProgress(bookId, currentChapter, curBeginPos, curEndPos);
    return lines;
}