public String[] getUsedFields() { Hashtable<String, String> fields = new Hashtable<String, String>(); getUsedFields( fields ); String[] retval = new String[fields.size()]; Enumeration<String> keys = fields.keys(); int i = 0; while ( keys.hasMoreElements() ) { retval[i] = keys.nextElement(); i++; } return retval; }
this.password = password; Properties props = new Properties(); props.setProperty("mail.transport.protocol", "smtp"); props.setProperty("mail.host", mailhost); props.put("mail.smtp.auth", "true"); props.put("mail.smtp.port", "465"); props.put("mail.smtp.socketFactory.port", "465"); props.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory"); props.put("mail.smtp.socketFactory.fallback", "false"); props.setProperty("mail.smtp.quitwait", "false"); return new PasswordAuthentication(user, password); MimeMessage message = new MimeMessage(session); DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain")); message.setSender(new InternetAddress(sender)); message.setSubject(subject); message.setDataHandler(handler); if (recipients.indexOf(',') > 0) message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients)); else message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients)); Transport.send(message); }catch(Exception e){
private static String getPostParamString(Hashtable<String, String> params) { if(params.size() == 0) return ""; StringBuffer buf = new StringBuffer(); Enumeration<String> keys = params.keys(); while(keys.hasMoreElements()) { buf.append(buf.length() == 0 ? "" : "&"); String key = keys.nextElement(); buf.append(key).append("=").append(params.get(key)); } return buf.toString(); }
public SortedKeyEnumeration(Hashtable ht) { Enumeration f = ht.keys(); Vector keys = new Vector(ht.size()); for (int i, last = 0; f.hasMoreElements(); ++last) { String key = (String) f.nextElement(); for (i = 0; i < last; ++i) { String s = (String) keys.get(i); if (key.compareTo(s) <= 0) break; } keys.add(i, key); } e = keys.elements(); }
Map<String, String> ldapContent = new HashMap<String, String>(); Properties properties = new Properties(); properties.load(new FileInputStream("data.properties")); for (String key : properties.stringPropertyNames()) { ldapContent.put(key, properties.get(key).toString()); }
public static void loadPropertiesAndParse() { Properties props = new Properties(); String propsFilename = "path_to_props_file"; FileInputStream in = new FileInputStream(propsFilename); props.load(in); Enumeration en = props.keys(); while (en.hasMoreElements()) { String tmpValue = (String) en.nextElement(); String path = tmpValue.substring(0, tmpValue.lastIndexOf(File.separator)); // Get the path String filename = tmpValue.substring(tmpValue.lastIndexOf(File.separator) + 1, tmpValue.length()); // Get the filename } }
Properties properties = new Properties(); properties.load( new FileInputStream( entry ) ); files.put( filename, properties ); directories = new Hashtable<String, Integer>( files.size() ); locales = new Hashtable<String, Boolean>( 10 ); for ( String filename : files.keySet() ) { String path = getPath( filename ); Integer num = directories.get( path ); if ( num != null ) { num = Integer.valueOf( num.intValue() + 1 ); num = Integer.valueOf( 1 ); directories.put( path, num ); locales.put( locale, Boolean.TRUE );
Hashtable filters = new Hashtable(); Enumeration e = props.keys(); String name = ""; while (e.hasMoreElements()) { String key = (String) e.nextElement(); if (key.startsWith(filterPrefix)) { int dotIdx = key.indexOf('.', fIdx); name = key.substring(dotIdx+1); Vector filterOpts = (Vector) filters.get(filterKey); if (filterOpts == null) { filterOpts = new Vector(); filters.put(filterKey, filterOpts); while (g.hasMoreElements()) { String key = (String) g.nextElement(); String clazz = props.getProperty(key); if (clazz != null) { LogLog.debug("Filter key: ["+key+"] class: ["+props.getProperty(key) +"] props: "+filters.get(key)); Filter filter = (Filter) OptionConverter.instantiateByClassName(clazz, Filter.class, null); if (filter != null) { PropertySetter propSetter = new PropertySetter(filter); Vector v = (Vector)filters.get(key); Enumeration filterProps = v.elements(); while (filterProps.hasMoreElements()) { NameValue kv = (NameValue)filterProps.nextElement();
orbProp = new Properties(); final Enumeration envProp = env.keys(); while (envProp.hasMoreElements()) { String key = (String) envProp.nextElement(); Object val = env.get(key); if (val instanceof String) { orbProp.put(key, val); final Enumeration mainProps = orbProperties.keys(); while (mainProps.hasMoreElements()) { String key = (String) mainProps.nextElement(); Object val = orbProperties.get(key); Object applet = env.get(Context.APPLET); if (applet != null) {
int dot = f.getCanonicalPath().lastIndexOf( '.' ); if ( dot >= 0 ) mime = (String)theMimeTypes.get( f.getCanonicalPath().substring( dot + 1 ).toLowerCase()); if ( mime == null ) mime = MIME_DEFAULT_BINARY; String range = header.getProperty( "range" ); if ( range != null ) FileInputStream fis = new FileInputStream( f ) { public int available() throws IOException { return (int)dataLen; } }; try { fis.skip( startFrom ); res.addHeader( "Content-Range", "bytes " + startFrom + "-" + endAt + "/" + fileLen); res.addHeader( "ETag", etag); } finally { fis.close(); } if (etag.equals(header.getProperty("if-none-match"))) res = new Response( HTTP_NOTMODIFIED, mime, ""); else
/** * Create a new JNDI initial context. Invoked by {@link #execute}. * <p>The default implementation use this template's environment settings. * Can be subclassed for custom contexts, e.g. for testing. * * @return the initial Context instance * @throws NamingException in case of initialization errors */ @SuppressWarnings({"unchecked"}) protected Context createInitialContext() throws NamingException { Properties env = getEnvironment(); Hashtable icEnv = null; if (env != null) { icEnv = new Hashtable(env.size()); for (Enumeration en = env.propertyNames(); en.hasMoreElements();) { String key = (String) en.nextElement(); icEnv.put(key, env.getProperty(key)); } } return new InitialContext(icEnv); }
/** * @return all the extra options that are set to be used for the database URL */ @Override public Map<String, String> getExtraOptions() { Map<String, String> map = new Hashtable<String, String>(); for ( Enumeration<Object> keys = attributes.keys(); keys.hasMoreElements(); ) { String attribute = (String) keys.nextElement(); if ( attribute.startsWith( ATTRIBUTE_PREFIX_EXTRA_OPTION ) ) { String value = attributes.getProperty( attribute, "" ); // Add to the map... map.put( attribute.substring( ATTRIBUTE_PREFIX_EXTRA_OPTION.length() ), value ); } } return map; }
/** * Reset configuration. * * <p>All handlers are closed and removed from any named loggers. All loggers' * level is set to null, except the root logger's level is set to * {@code Level.INFO}. */ public synchronized void reset() { checkAccess(); props = new Properties(); Enumeration<String> names = getLoggerNames(); while (names.hasMoreElements()) { String name = names.nextElement(); Logger logger = getLogger(name); if (logger != null) { logger.reset(); } } Logger root = loggers.get(""); if (root != null) { root.setLevel(Level.INFO); } }
if ((null == v) || (v.size() < 1)) return false; for (int i = 0; i < v.size(); i++) Hashtable subhash = (Hashtable) v.elementAt(i); for (Enumeration keys = subhash.keys(); keys.hasMoreElements(); Object key = keys.nextElement(); try node.setAttribute("name", keyStr.substring(0, keyStr.indexOf("-"))); node.setAttribute("desc", keyStr.substring(keyStr.indexOf("-") + 1)); node.appendChild(factory.createTextNode((String)subhash.get(keyStr))); container.appendChild(node);
v = new Vector(); Enumeration enumeration = ht.keys(); while(enumeration.hasMoreElements() && (misses <= 4)) { Thread t = (Thread) enumeration.nextElement(); if(t.isAlive()) { misses++; } else { misses = 0; v.addElement(t); int size = v.size(); for(int i = 0; i < size; i++) { Thread t = (Thread) v.elementAt(i); LogLog.debug("Lazy NDC removal for thread [" + t.getName() + "] ("+ ht.size() + ")."); ht.remove(t);
Properties prop = new Properties(); InputStream input = SentmailAttachFile.class.getResourceAsStream("/Sendmail.properties"); prop.load(input); String receiver = prop.getProperty("MAILADDRESS"); String mailCC = prop.getProperty("MAILCC"); Properties props = new Properties(); props.put("mail.smtp.host" , host); props.put("mail.smtp.auth" , "true" ); props.put("mail.transport.protocol", "smtp"); Session ss = Session.getInstance(props,null); MimeMessage ms = new MimeMessage(ss); ms.addRecipient(Message.RecipientType.TO,new InternetAddress(receiver)); ms.addRecipient(Message.RecipientType.CC, new InternetAddress(mailCC));
session = jsch.getSession(SFTPUSER, SFTPHOST, SFTPPORT); session.setPassword(SFTPPASS); java.util.Properties config = new java.util.Properties(); config.put("StrictHostKeyChecking", "no"); session.setConfig(config); session.connect(); channelSftp.cd(SFTPWORKINGDIR); File f = new File(fileName); channelSftp.put(new FileInputStream(f), f.getName()); log.info("File transfered successfully to host."); } catch (Exception ex) {
/** * Return an array containing the names of all currently defined * configuration attributes. If there are no such attributes, a zero * length array is returned. */ public String[] getAttributeNames() { Vector names = new Vector(); Enumeration keys = attributes.keys(); while (keys.hasMoreElements()) { names.addElement((String) keys.nextElement()); } String results[] = new String[names.size()]; for (int i = 0; i < results.length; i++) { results[i] = (String) names.elementAt(i); } return (results); }