List of usage examples for java.util Vector addElement
public synchronized void addElement(E obj)
From source file:FileUtil.java
public static Vector removeDuplicates(Vector s) { int i = 0;//from w w w .j a va 2s . c o m int j = 0; boolean duplicates = false; Vector v = new Vector(); for (i = 0; i < s.size(); i++) { duplicates = false; for (j = (i + 1); j < s.size(); j++) { if (s.elementAt(i).toString().equalsIgnoreCase(s.elementAt(j).toString())) { duplicates = true; } } if (duplicates == false) { v.addElement(s.elementAt(i).toString().trim()); } } return v; }
From source file:org.apache.nutch.tools.DmozParser.java
private static void addTopicsFromFile(String topicFile, Vector<String> topics) throws IOException { BufferedReader in = null;/* w w w . ja v a 2 s .co m*/ try { in = new BufferedReader(new InputStreamReader(new FileInputStream(topicFile), "UTF-8")); String line = null; while ((line = in.readLine()) != null) { topics.addElement(new String(line)); } } catch (Exception e) { if (LOG.isFatalEnabled()) { LOG.fatal(e.toString()); e.printStackTrace(LogUtil.getFatalStream(LOG)); } System.exit(0); } finally { in.close(); } }
From source file:com.myJava.util.Util.java
/** * Split a String in an array of Strings */// www .j a v a 2 s . co m public static Vector split(String orig, String pattern) { if (orig == null || pattern == null) { return null; } int currentIndex = orig.indexOf(pattern); int lastIndex = 0; Vector elements = new Vector(); while (currentIndex != -1) { elements.addElement(orig.substring(lastIndex, currentIndex)); lastIndex = currentIndex + pattern.length(); currentIndex = orig.indexOf(pattern, lastIndex); } elements.addElement(orig.substring(lastIndex, orig.length())); return elements; }
From source file:com.substanceofcode.twitter.model.Status.java
private static Enumeration findMedia(JSONObject status) { JSONObject je;//ww w. ja v a 2 s .c o m try { je = status.getJSONObject("entities"); } catch (JSONException jsonex) { return null; } if (je == null) { return null; } try { JSONArray jsa = je.getJSONArray("urls"); if (jsa != null) { for (int j = 0; j < jsa.length(); j++) { JSONObject jo = jsa.getJSONObject(j); String tco = jo.getString("url"); String exp = jo.getString("expanded_url"); if (tco != null && exp != null) { tCoResolver.add(tco, exp); } } } } catch (JSONException jsonex) { Log.error(jsonex.toString()); } Vector media = new Vector(); try { JSONArray jsa = je.getJSONArray("media"); for (int j = 0; j < jsa.length(); j++) { try { JSONObject jo = jsa.getJSONObject(j); String mu = jo.getString("media_url"); if (mu != null) { media.addElement(mu); String url = jo.getString("url"); if (url != null) { tCoResolver.add(url, mu); } } } catch (JSONException jsonex) { } } } catch (JSONException jsonex) { } return media.elements(); }
From source file:Main.java
/** * Reads the next xml attribute in a tag. * @return A vector with two elements. The first element is * the xml attributes key and the second its value as a String */// ww w .j ava 2s . co m public static Vector getNextAttribute(InputStream is) { errormessage = null; Vector Res = new Vector(); try { char c; sb.setLength(0); if (lastchar == '>') return Res; else c = findChar(is, delimiters, false); if (c == '>') { lastchar = '>'; return Res; } sb.setLength(0); sb.append(c); getNextWord(is); String U = sb.toString(); sb.setLength(0); Res.addElement(U); if (lastchar == '=') c = lastchar; else { c = findChar(is, " \n\r\f\t", false); } if (c != '=') { errormessage = "Improperly formed attribute. Need =" + U + "::" + c; return null; } c = findChar(is, " \t\r\n\f", false); if (c != '\"') { errormessage = "Attribute values must be quoted " + c + U; return null; } sb.setLength(0); for (c = (char) is.read(); c != '\"'; c = (char) is.read()) sb.append(c); lastchar = 0; Res.addElement(sb.toString()); //lastchar = c; return Res; } catch (Exception s) { errormessage = s.getMessage(); return null; } }
From source file:com.phonegap.PhoneGap.java
public static final String[] splitString(final String data, final char splitChar, final boolean allowEmpty) { Vector v = new Vector(); int indexStart = 0; int indexEnd = data.indexOf(splitChar); if (indexEnd != -1) { while (indexEnd != -1) { String s = data.substring(indexStart, indexEnd); if (allowEmpty || s.length() > 0) { v.addElement(s); }// ww w .ja v a 2 s .c o m s = null; indexStart = indexEnd + 1; indexEnd = data.indexOf(splitChar, indexStart); } if (indexStart != data.length()) { // Add the rest of the string String s = data.substring(indexStart); if (allowEmpty || s.length() > 0) { v.addElement(s); } s = null; } } else { if (allowEmpty || data.length() > 0) { v.addElement(data); } } String[] result = new String[v.size()]; v.copyInto(result); v = null; return result; }
From source file:funcoes.funcoes.java
@SuppressWarnings("rawtypes") public static Vector<Comparable> proximaLinha(ResultSet rs, ResultSetMetaData rsmd) throws SQLException { Vector<Comparable> LinhaAtual = new Vector<Comparable>(); try {//from w w w . ja v a 2 s . c om for (int i = 1; i <= rsmd.getColumnCount(); ++i) { switch (rsmd.getColumnType(i)) { case Types.VARCHAR: LinhaAtual.addElement(rs.getString(i)); break; case Types.TIMESTAMP: LinhaAtual.addElement(rs.getDate(i).toLocaleString().substring(0, 10)); break; case Types.INTEGER: LinhaAtual.addElement(rs.getInt(i)); break; case Types.DECIMAL: LinhaAtual.addElement(funcoes.paraFormatoDinheiro(rs.getDouble(i))); break; case Types.DOUBLE: LinhaAtual.addElement(funcoes.paraFormatoDinheiro(rs.getDouble(i))); break; } } } catch (SQLException e) { } return LinhaAtual; }
From source file:com.thoughtworks.go.util.SelectorUtils.java
/** * Breaks a path up into a Vector of path elements, tokenizing on * * @param path Path to tokenize. Must not be <code>null</code>. * @param separator the separator against which to tokenize. * * @return a Vector of path elements from the tokenized path * @since Ant 1.6/* w w w . j av a2s . c o m*/ */ public static Vector tokenizePath(String path, String separator) { Vector ret = new Vector(); if (FileUtil.isAbsolutePath(path)) { String[] s = FileUtil.dissect(path); ret.add(s[0]); path = s[1]; } StringTokenizer st = new StringTokenizer(path, separator); while (st.hasMoreTokens()) { ret.addElement(st.nextToken()); } return ret; }
From source file:localization.split.java
public static Vector<String> readzipfile(String filepath) { Vector<String> v = new Vector<String>(); byte[] buffer = new byte[1024]; String outputFolder = filepath.substring(0, filepath.lastIndexOf(".")); System.out.println(outputFolder); try {/*from w w w . java 2s . c o m*/ File folder = new File(outputFolder); if (!folder.exists()) { folder.mkdir(); } ZipInputStream zis = new ZipInputStream(new FileInputStream(filepath)); ZipEntry ze = zis.getNextEntry(); while (ze != null) { String fileName = ze.getName(); File newFile = new File(outputFolder + "\\" + fileName); v.addElement(newFile.getAbsolutePath()); FileOutputStream fos = new FileOutputStream(newFile); int len; while ((len = zis.read(buffer)) > 0) { fos.write(buffer, 0, len); } fos.close(); ze = zis.getNextEntry(); } zis.closeEntry(); zis.close(); } catch (Exception e) { } return v; }
From source file:nl.ellipsis.webdav.server.util.XMLHelper.java
public static Vector<String> getPropertiesFromXML(Node propNode) { Vector<String> properties; properties = new Vector<String>(); NodeList childList = propNode.getChildNodes(); for (int i = 0; i < childList.getLength(); i++) { Node currentNode = childList.item(i); if (currentNode.getNodeType() == Node.ELEMENT_NODE) { String nodeName = currentNode.getLocalName(); String namespace = currentNode.getNamespaceURI(); String propertyName = null; if (nodeName.indexOf(':') != -1) { propertyName = nodeName.substring(nodeName.indexOf(':') + 1); } else { propertyName = nodeName; }/* w ww. j a v a 2 s.c o m*/ // href is a live property which is handled differently properties.addElement(propertyName); } } return properties; }