Java Code Examples for java.util.Properties

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project activejdbc, under directory /activejdbc/src/test/java/org/javalite/activejdbc/.

Source file: ConnectionSpecTest.java

  33 
vote

@Test public void testJdbcWithProperties(){
  Properties p=new Properties();
  p.setProperty("user",user());
  p.setProperty("password",password());
  ConnectionJdbcSpec spec=new ConnectionJdbcSpec(driver(),url(),p);
  jdbcWithSpec(spec);
}
 

Example 2

From project activemq-apollo, under directory /apollo-openwire/src/main/scala/org/apache/activemq/apollo/openwire/support/.

Source file: MarshallingSupport.java

  32 
vote

public static Properties stringToProperties(String str) throws IOException {
  Properties result=new Properties();
  if (str != null && str.length() > 0) {
    DataByteArrayInputStream dataIn=new DataByteArrayInputStream(str.getBytes());
    result.load(dataIn);
    dataIn.close();
  }
  return result;
}
 

Example 3

From project addis, under directory /application/src/main/java/org/drugis/addis/.

Source file: AppInfo.java

  32 
vote

private static String getProperty(String property,String fallback){
  try {
    InputStream is=AppInfo.class.getResourceAsStream("/META-INF/maven/org.drugis.addis/application/pom.properties");
    Properties props=new Properties();
    props.load(is);
    return props.getProperty(property,fallback);
  }
 catch (  Exception e) {
    return fallback;
  }
}
 

Example 4

From project AdServing, under directory /modules/utilities/common/src/main/java/net/mad/ads/common/util/.

Source file: Properties2.java

  32 
vote

static public Properties loadProperties(File propertiesFile) throws IOException {
  InputStream is=null;
  is=new FileInputStream(propertiesFile);
  Properties prop=new Properties();
  prop.load(is);
  return new XProperties(prop);
}
 

Example 5

From project aether-ant, under directory /src/main/java/org/eclipse/aether/ant/.

Source file: AntRepoSys.java

  32 
vote

private Properties getSystemProperties(){
  Properties props=new Properties();
  getEnvProperties(props);
  props.putAll(System.getProperties());
  ConverterUtils.addProperties(props,project.getProperties());
  return props;
}
 

Example 6

From project aether-core, under directory /aether-impl/src/main/java/org/eclipse/aether/internal/impl/.

Source file: DefaultUpdateCheckManager.java

  32 
vote

public void touchArtifact(RepositorySystemSession session,UpdateCheck<Artifact,ArtifactTransferException> check){
  Artifact artifact=check.getItem();
  File artifactFile=check.getFile();
  File touchFile=getTouchFile(artifact,artifactFile);
  String updateKey=getUpdateKey(session,artifactFile,check.getRepository());
  String dataKey=getDataKey(artifact,artifactFile,check.getAuthoritativeRepository());
  String transferKey=getTransferKey(session,artifact,artifactFile,check.getRepository());
  setUpdated(session.getData(),updateKey);
  Properties props=write(touchFile,dataKey,transferKey,check.getException());
  if (artifactFile.exists() && !hasErrors(props)) {
    touchFile.delete();
  }
}
 

Example 7

From project agile, under directory /agile-runtime/src/main/java/org/headsupdev/agile/runtime/.

Source file: Main.java

  32 
vote

protected static Properties loadConfiguration(){
  Main.loadSystemProperties();
  Properties configProps=Main.loadConfigProperties();
  if (configProps == null) {
    System.err.println("No " + CONFIG_PROPERTIES_FILE_VALUE + " found.");
    configProps=new Properties();
  }
  Main.copySystemProperties(configProps);
  return configProps;
}
 

Example 8

From project Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/dataholders/loadingutils/.

Source file: XmlMerger.java

  32 
vote

/** 
 * Check for modifications of included files.
 * @return <code>true</code> if at least one of included files has modifications.
 * @throws IOException                  IO Error.
 * @throws SAXException                 Document parsing error.
 * @throws ParserConfigurationException if a SAX parser cannotbe created which satisfies the requested configuration.
 */
private boolean checkFileModifications() throws Exception {
  long destFileTime=destFile.lastModified();
  if (sourceFile.lastModified() > destFileTime) {
    logger.debug("Source file was modified ");
    return true;
  }
  Properties metadata=restoreFileModifications(metaDataFile);
  if (metadata == null)   return true;
  SAXParserFactory parserFactory=SAXParserFactory.newInstance();
  SAXParser parser=parserFactory.newSAXParser();
  TimeCheckerHandler handler=new TimeCheckerHandler(baseDir,metadata);
  parser.parse(sourceFile,handler);
  return handler.isModified();
}
 

Example 9

From project airlift, under directory /configuration/src/main/java/io/airlift/configuration/.

Source file: ConfigurationLoader.java

  32 
vote

/** 
 * Loads properties from the given file
 * @param path file path
 * @return properties
 * @throws IOException errors
 */
public Map<String,String> loadPropertiesFrom(String path) throws IOException {
  Reader reader=new FileReader(new File(path));
  Properties properties=new Properties();
  try {
    properties.load(reader);
  }
  finally {
    reader.close();
  }
  return toMap(properties);
}
 

Example 10

From project AirReceiver, under directory /src/main/java/org/phlo/AirReceiver/.

Source file: AirReceiver.java

  32 
vote

/** 
 * Reads the version from the version.properties file
 * @return the version
 */
private static String getVersion(){
  Properties versionProperties=new Properties();
  final InputStream versionPropertiesStream=AirReceiver.class.getClassLoader().getResourceAsStream("version.properties");
  try {
    versionProperties.load(versionPropertiesStream);
  }
 catch (  final IOException e) {
    throw new RuntimeException(e.getMessage(),e);
  }
  return versionProperties.getProperty("org.phlo.AirReceiver.version");
}
 

Example 11

From project ajah, under directory /ajah-rfcmail/src/main/java/com/ajah/rfcmail/fetch/.

Source file: IMAPMailFetcher.java

  32 
vote

/** 
 * Fetches mail from default folder and all child folders.
 */
@Override public void go() throws MessagingException, IOException {
  final Properties props=System.getProperties();
  props.setProperty("mail.store.protocol","imaps");
  final Session session=Session.getDefaultInstance(props,null);
  final Store store=session.getStore("imaps");
  store.connect(getHostname(),getUsername(),getPassword());
  log.fine("Connected to: " + store);
  final IMAPFolder defaultFolder=(IMAPFolder)store.getDefaultFolder();
  log.fine("Default folder is: " + defaultFolder.getFullName());
  processFolder(defaultFolder);
}
 

Example 12

From project alfredo, under directory /alfredo/src/main/java/com/cloudera/alfredo/server/.

Source file: AuthenticationFilter.java

  32 
vote

/** 
 * Returns the filtered configuration (only properties starting with the specified prefix). The property keys are also trimmed from the prefix. The returned <code>Properties</code> object is used to initialized the {@link AuthenticationHandler}. <p/> This method can be overriden by subclasses to obtain the configuration from other configuration source than the web.xml file.
 * @param configPrefix configuration prefix to use for extracting configuration properties.
 * @param filterConfig filter configuration object
 * @return the configuration to be used with the {@link AuthenticationHandler} instance.
 * @throws ServletException thrown if the configuration could not be created.
 */
protected Properties getConfiguration(String configPrefix,FilterConfig filterConfig) throws ServletException {
  Properties props=new Properties();
  Enumeration names=filterConfig.getInitParameterNames();
  while (names.hasMoreElements()) {
    String name=(String)names.nextElement();
    if (name.startsWith(configPrefix)) {
      String value=filterConfig.getInitParameter(name);
      props.put(name.substring(configPrefix.length()),value);
    }
  }
  return props;
}
 

Example 13

From project ALP, under directory /workspace/alp-reporter/src/main/java/com/lohika/alp/mailer/.

Source file: MailerConfigurator.java

  32 
vote

/** 
 * Builds the properties.
 * @return the properties
 */
public Properties buildProperties(){
  Properties to_ret=new Properties();
  if (authNeed) {
    to_ret.setProperty("mail.smtp.submitter",getSmtpUser());
    to_ret.setProperty("mail.smtp.auth","true");
  }
  if (smtpSsl) {
    to_ret.setProperty("mail.smtp.ssl","true");
    to_ret.setProperty("mail.smtp.socketFactory.class","javax.net.ssl.SSLSocketFactory");
  }
  to_ret.setProperty("mail.smtp.host",smtpHost);
  to_ret.setProperty("mail.smtp.port",getSmtpPort());
  return to_ret;
}
 

Example 14

From project ambrose, under directory /pig/src/main/java/com/twitter/ambrose/pig/.

Source file: AmbrosePigProgressNotificationListener.java

  32 
vote

/** 
 * Collects statistics from JobStats and builds a nested Map of values. Subsclass ond override if you'd like to generate different stats.
 * @param scriptId
 * @param stats
 * @return
 */
protected JobInfo collectStats(String scriptId,JobStats stats){
  Properties jobConfProperties=new Properties();
  if (stats.getInputs() != null && stats.getInputs().size() > 0 && stats.getInputs().get(0).getConf() != null) {
    Configuration conf=stats.getInputs().get(0).getConf();
    for (    Map.Entry<String,String> entry : conf) {
      jobConfProperties.setProperty(entry.getKey(),entry.getValue());
    }
    if (workflowVersion == null) {
      workflowVersion=conf.get("pig.logical.plan.signature");
    }
  }
  return new PigJobInfo(stats,jobConfProperties);
}
 

Example 15

From project Amoeba-for-Aladdin, under directory /src/java/com/meidusa/amoeba/jdbc/.

Source file: DriverWrapper.java

  32 
vote

/** 
 * ????????? URL ???????
 */
public Connection connect(String url,Properties info) throws SQLException {
  Properties p=new Properties();
  p.putAll(info);
  Connection conn=driver.connect(url,p);
  CharsetParameter param=new CharsetParameter();
  param.setClientEncoding(this.getClientEncoding());
  param.setServerEncoding(this.getServerEncoding());
  return factory.getConnection(param,conn);
}
 

Example 16

From project anadix, under directory /anadix-tests/src/test/java/org/anadix/html/.

Source file: FrameTagTest.java

  32 
vote

@BeforeTest public void prepareAttributes(){
  Properties p=new Properties();
  p.setProperty("width","100px;");
  noTitle=new Attributes(p);
  p.setProperty("title",title);
  withTitle=new Attributes(p);
  ft=new FrameTag(id,parent,noTitle);
}
 

Example 17

From project and-bible, under directory /AndBible/src/net/bible/service/readingplan/.

Source file: ReadingPlanDao.java

  32 
vote

/** 
 * get readings for one day
 */
public OneDaysReadingsDto getReading(String planName,int dayNo){
  Properties properties=getPlanProperties(planName);
  String readings=(String)properties.get(Integer.toString(dayNo));
  Log.d(TAG,"Readings for day:" + readings);
  return new OneDaysReadingsDto(dayNo,readings,getReadingPlanInfoDto(planName));
}
 

Example 18

From project Android-DB-Editor, under directory /src/com/troido/dbeditor/.

Source file: TreeMouseListener.java

  32 
vote

public TreeMouseListener(){
  if (sqlitepath == null) {
    try {
      Properties props=new Properties();
      String iniPath=new File(TreeMouseListener.class.getProtectionDomain().getCodeSource().getLocation().getPath()).getParent() + "/settings.ini";
      props.load(new FileReader(iniPath));
      sqlitepath=props.getProperty("sqliteeditorpath");
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}
 

Example 19

From project android-rindirect, under directory /maven-rindirect-plugin-it/src/test/java/de/akquinet/android/rindirect/.

Source file: ClassnameTest.java

  32 
vote

@Test public void testClassname() throws VerificationException, FileNotFoundException, IOException {
  Verifier verifier=new Verifier(ROOT.getAbsolutePath());
  Properties props=Constants.getSystemProperties();
  props.put("rindirect.classname","MyS");
  verifier.setSystemProperties(props);
  verifier.executeGoal("package");
  verifier.verifyTextInLog("BUILD SUCCESS");
  Helper.checkExecution(verifier);
  verifier.resetStreams();
  File result=new File(ROOT + Constants.GENERATE_FOLDER + "/my/application/MyS.java");
  Assert.assertTrue(result.exists());
}
 

Example 20

From project Android-SQL-Helper, under directory /src/com/sgxmobileapps/androidsqlhelper/processor/model/.

Source file: Schema.java

  32 
vote

public void storeSchemaProperties(File outDir) throws IOException {
  Properties props=new Properties();
  props.setProperty(KEY_PACKAGE,mPackage);
  props.setProperty(KEY_ADAPTER_CLASS_NAME,mDbAdapterClassName);
  props.setProperty(KEY_METADATA_CLASS_NAME,mMetadataClassName);
  props.setProperty(KEY_DB_NAME,mDbName);
  props.setProperty(KEY_DB_VERSION,mDbVersion);
  props.setProperty(KEY_AUTHOR,mAuthor);
  props.setProperty(KEY_LICENSE,mLicense);
  props.setProperty(KEY_LICENSE_FILE,mLicenseFile);
  props.store(new FileOutputStream(new File(outDir,SCHEMA_PROPERTIES_FILE)),null);
}
 

Example 21

From project androidpn, under directory /androidpn-client/src/org/androidpn/client/.

Source file: ServiceManager.java

  32 
vote

private Properties loadProperties(){
  Properties props=new Properties();
  try {
    int id=context.getResources().getIdentifier("androidpn","raw",context.getPackageName());
    props.load(context.getResources().openRawResource(id));
  }
 catch (  Exception e) {
    Log.e(LOGTAG,"Could not find the properties file.",e);
  }
  return props;
}
 

Example 22

From project android_external_oauth, under directory /core/src/main/java/net/oauth/.

Source file: ConsumerProperties.java

  32 
vote

public static Properties getProperties(URL source) throws IOException {
  InputStream input=source.openStream();
  try {
    Properties p=new Properties();
    p.load(input);
    return p;
  }
  finally {
    input.close();
  }
}
 

Example 23

From project androlog, under directory /androlog/src/test/java/de/akquinet/android/androlog/.

Source file: LogTest.java

  32 
vote

@Test public void testActivationFromProperties() throws FileNotFoundException, IOException {
  File config=new File("src/test/resources/androlog-active.properties");
  Properties props=new Properties();
  props.load(new FileInputStream(config));
  Log.reset();
  Log.configure(props);
  assertTrue(Log.isLoggable("any",Constants.INFO));
  assertTrue(Log.isLoggable(this,Constants.INFO));
}
 

Example 24

From project 16Blocks, under directory /src/main/java/de/minestar/sixteenblocks/Commands/.

Source file: cmdSlots.java

  31 
vote

private void setSlots(String[] args,CommandSender sender){
  try {
    Integer maxPlayer=Integer.valueOf(args[0]);
    CraftServer server=(CraftServer)Bukkit.getServer();
    server.getHandle().maxPlayers=maxPlayer;
    ChatUtils.writeSuccess(sender,"MaxPlayers set to " + maxPlayer + " !");
    Properties p=new Properties();
    BufferedReader bReader=new BufferedReader(new FileReader("server.properties"));
    p.load(bReader);
    bReader.close();
    p.setProperty("max-players",maxPlayer.toString());
    BufferedWriter bWriter=new BufferedWriter(new FileWriter("server.properties"));
    p.store(bWriter,"");
    bWriter.close();
  }
 catch (  IOException IOE) {
    ConsoleUtils.printException(IOE,"Can't update server.properties!");
  }
catch (  NumberFormatException e) {
    ChatUtils.writeError(sender,args[0] + " is not a number!");
  }
}
 

Example 25

From project accesointeligente, under directory /src/org/accesointeligente/server/.

Source file: ApplicationProperties.java

  31 
vote

@Override public void contextInitialized(ServletContextEvent event){
  try {
    properties=new Properties();
    properties.load(new FileInputStream(event.getServletContext().getRealPath("/WEB-INF/accesointeligente.properties")));
    logger.info("Context initialized");
  }
 catch (  Throwable ex) {
    logger.error("Failed to initialize context",ex);
  }
}
 

Example 26

From project AceWiki, under directory /src/ch/uzh/ifi/attempto/aceeditor/.

Source file: ACEEditor.java

  31 
vote

/** 
 * Returns information about ACE Editor, like the version number and the release date. This information is read from the file "aceeditor.properties".
 * @param key The key string.
 * @return The value for the given key.
 */
public static String getInfo(String key){
  if (properties == null) {
    String f="ch/uzh/ifi/attempto/aceeditor/aceeditor.properties";
    InputStream in=Thread.currentThread().getContextClassLoader().getResourceAsStream(f);
    properties=new Properties();
    try {
      properties.load(in);
    }
 catch (    Exception ex) {
      ex.printStackTrace();
    }
  }
  return properties.getProperty(key);
}
 

Example 27

From project adbcj, under directory /jdbc/src/main/java/org/adbcj/jdbc/.

Source file: JdbcConnectionManager.java

  31 
vote

public JdbcConnectionManager(String jdbcUrl,String username,String password,ExecutorService executorService,Properties properties){
  this.jdbcUrl=jdbcUrl;
  this.properties=new Properties(properties);
  this.executorService=executorService;
  this.properties.put(USER,username);
  this.properties.put(PASSWORD,password);
}
 

Example 28

From project agileBase, under directory /gtpb_server/src/com/gtwm/pb/util/.

Source file: Helpers.java

  31 
vote

public static void sendEmail(Set<String> recipients,String body,String subject) throws MessagingException {
  Properties props=new Properties();
  props.setProperty("mail.smtp.host","localhost");
  Session mailSession=Session.getDefaultInstance(props,null);
  MimeMessage message=new MimeMessage(mailSession);
  message.setSubject(subject);
  for (  String emailRecipient : recipients) {
    Address toAddress=new InternetAddress(emailRecipient);
    message.addRecipient(Message.RecipientType.TO,toAddress);
  }
  Address fromAddress=new InternetAddress("notifications@agilebase.co.uk");
  message.setFrom(fromAddress);
  message.setText(body);
  Transport.send(message);
  logger.info("Sent message '" + subject + "' to "+ recipients);
}
 

Example 29

From project agit, under directory /agit-test-utils/src/main/java/com/madgag/agit/.

Source file: GitTestUtils.java

  31 
vote

public static String gitServerHostAddress() throws IOException, UnknownHostException {
  File hostAddressFile=new File(Environment.getExternalStorageDirectory(),"agit-integration-test.properties");
  Properties properties=new Properties();
  if (hostAddressFile.exists()) {
    properties.load(new FileInputStream(hostAddressFile));
  }
  String[] hostAddresses=properties.getProperty("gitserver.host.address","10.0.2.2").split(",");
  for (  String hostAddress : hostAddresses) {
    if (InetAddress.getByName(hostAddress).isReachable(1000)) {
      Log.d(TAG,"Using git server host : " + hostAddress);
      return hostAddress;
    }
  }
  throw new RuntimeException("No reachable addresses in " + asList(hostAddresses));
}
 

Example 30

From project AmDroid, under directory /AmenLib/src/test/java/com/jaeckel/amenoid/api/.

Source file: AmenServiceITest.java

  31 
vote

@Override public void setUp() throws IOException {
  Properties props=new Properties();
  try {
    props.load(this.getClass().getResourceAsStream("test.properties"));
  }
 catch (  IOException e) {
    throw new RuntimeException("Properties not loaded",e);
  }
  username=props.getProperty("amenlib.tests.username");
  password=props.getProperty("amenlib.tests.password");
  if ("${tests.username}".equals(username)) {
    System.out.println("Please put username and password in settings.xml. See README ");
  }
  InputStream in=ClassLoader.getSystemResourceAsStream("amenkeystore");
  amenHttpClient=new AmenHttpClient(in,"mysecret","JKS");
  service=new AmenServiceImpl(amenHttpClient);
  service.init(username,password);
}
 

Example 31

From project android-client, under directory /xwiki-android-test-fixture-setup/src/org/xwiki/test/integration/utils/.

Source file: XWikiExecutor.java

  31 
vote

/** 
 * @deprecated since 4.2M1 use {@link #getPropertiesConfiguration(String)} instead
 */
@Deprecated private Properties getProperties(String path) throws Exception {
  Properties properties=new Properties();
  FileInputStream fis;
  try {
    fis=new FileInputStream(path);
    try {
      properties.load(fis);
    }
  finally {
      fis.close();
    }
  }
 catch (  FileNotFoundException e) {
    LOGGER.debug("Failed to load properties [" + path + "]",e);
  }
  return properties;
}
 

Example 32

From project android-rackspacecloud, under directory /main/java/net/elasticgrid/rackspace/common/.

Source file: RackspaceConnection.java

  31 
vote

/** 
 * Initializes the Rackspace connection with the Rackspace login information.
 * @param username the Rackspace username
 * @param apiKey   the Rackspace API key
 * @throws RackspaceException if the credentials are invalid
 * @throws IOException        if there is a network issue
 * @see #authenticate()
 */
public RackspaceConnection(String username,String apiKey) throws RackspaceException, IOException {
  this.username=username;
  this.apiKey=apiKey;
  String version;
  try {
    Properties props=new Properties();
    props.load(this.getClass().getClassLoader().getResourceAsStream("version.properties"));
    version=props.getProperty("version");
  }
 catch (  Exception ex) {
    version="?";
  }
  userAgent=userAgent + version + " ("+ System.getProperty("os.arch")+ "; "+ System.getProperty("os.name")+ ")";
  authenticate();
}
 

Example 33

From project android-sdk, under directory /src/main/java/com/mobeelizer/mobile/android/.

Source file: MobeelizerApplication.java

  31 
vote

public static MobeelizerApplication createApplicationForTitanium(final Application mobeelizer){
  MobeelizerApplication application=new MobeelizerApplication();
  Properties properties=new Properties();
  try {
    properties.load(application.getDefinitionXmlAsset(mobeelizer,"Resources/mobeelizer.properties"));
  }
 catch (  FileNotFoundException e) {
    throw new IllegalStateException("'mobeelizer.properties' file is required",e);
  }
catch (  IOException e) {
    throw new IllegalStateException(e.getMessage(),e);
  }
  String device=properties.getProperty("device");
  String developmentRole=properties.getProperty("role");
  String definitionXml=properties.getProperty("definitionXml");
  String url=properties.getProperty("url");
  String stringMode=properties.getProperty("mode");
  if (definitionXml == null) {
    definitionXml="application.xml";
  }
  definitionXml="Resources/" + definitionXml;
  application.initApplication(mobeelizer,device,null,developmentRole,definitionXml,1,url,stringMode);
  return application;
}
 

Example 34

From project android-tether, under directory /src/og/android/tether/system/.

Source file: WebserviceTask.java

  31 
vote

public static Properties queryForProperty(String url){
  Properties properties=null;
  HttpClient client=new DefaultHttpClient();
  HttpGet request=new HttpGet(String.format(url));
  try {
    HttpResponse response=client.execute(request);
    StatusLine status=response.getStatusLine();
    Log.d(MSG_TAG,"Request returned status " + status);
    if (status.getStatusCode() == 200) {
      HttpEntity entity=response.getEntity();
      properties=new Properties();
      properties.load(entity.getContent());
    }
  }
 catch (  IOException e) {
    Log.d(MSG_TAG,"Can't get property '" + url + "'.");
  }
  return properties;
}
 

Example 35

From project androidannotations, under directory /AndroidAnnotations/androidannotations/src/main/java/com/googlecode/androidannotations/helper/.

Source file: AndroidManifestFinder.java

  31 
vote

private AndroidManifest extractAndroidManifestThrowing() throws Exception {
  File androidManifestFile=findManifestFileThrowing();
  String projectDirectory=androidManifestFile.getParent();
  File projectProperties=new File(projectDirectory,"project.properties");
  boolean libraryProject=false;
  if (projectProperties.exists()) {
    Properties properties=new Properties();
    properties.load(new FileInputStream(projectProperties));
    if (properties.containsKey("android.library")) {
      String androidLibraryProperty=properties.getProperty("android.library");
      libraryProject=androidLibraryProperty.equals("true");
      Messager messager=processingEnv.getMessager();
      messager.printMessage(Kind.NOTE,"Found android.library property in project.properties, value: " + libraryProject);
    }
  }
  return parseThrowing(androidManifestFile,libraryProject);
}
 

Example 36

From project androidZenWriter, under directory /src/com/javaposse/android/zenwriter/.

Source file: AndroidZenWriterActivity.java

  31 
vote

public void saveSettings(){
  FileOutputStream fos=null;
  Properties settings=new Properties();
  for (int i=0; i < notes.size(); i++) {
    Note note=notes.get(i);
    String prefix="note." + i + ".";
    settings.setProperty(prefix + "id",note.id);
    settings.setProperty(prefix + "name",note.getName());
    settings.setProperty(prefix + "filename",note.getFilename());
    settings.setProperty(prefix + "new",note.isNew() ? "true" : "false");
    settings.setProperty(prefix + "lastModified",String.valueOf(note.getLastModified().getTime()));
    Log.i("saveSettings","Saving Note Metadata: " + note);
  }
  settings.setProperty("currentNoteId",currentNote.id);
  Log.i("saveSettings","currentNoteId: " + currentNote.id);
  try {
    fos=openFileOutput(settingsFilename,MODE_PRIVATE);
    settings.store(fos,"Settings saved at: " + new Date());
  }
 catch (  IOException e) {
    Log.e("SaveFile","Failed to save file: ",e);
  }
 finally {
    if (fos != null) {
      try {
        fos.close();
      }
 catch (      IOException e) {
      }
    }
  }
  Toast.makeText(this,"Saved settings",Toast.LENGTH_SHORT).show();
}
 

Example 37

From project Android_1, under directory /org.eclipse.ecf.android/src/org/eclipse/ecf/android/.

Source file: Client.java

  31 
vote

public Client(Socket aSocket,ObjectInputStream iStream,ObjectOutputStream oStream,ISynchAsynchEventHandler handler,int maxmsgs) throws IOException {
  Assert.assertNotNull(Messages.Client_Event_Handler_Not_Null);
  if (aSocket.getKeepAlive())   keepAlive=aSocket.getSoTimeout();
  setSocket(aSocket);
  inputStream=iStream;
  outputStream=oStream;
  this.handler=handler;
  containerID=handler.getEventHandlerID();
  maxMsg=maxmsgs;
  properties=new Properties();
  setupThreads();
}
 

Example 38

From project android_external_tagsoup, under directory /src/org/ccil/cowan/tagsoup/.

Source file: XMLWriter.java

  31 
vote

/** 
 * Internal initialization method. <p>All of the public constructors invoke this method.
 * @param writer The output destination, or null to usestandard output.
 */
private void init(Writer writer){
  setOutput(writer);
  nsSupport=new NamespaceSupport();
  prefixTable=new Hashtable();
  forcedDeclTable=new Hashtable();
  doneDeclTable=new Hashtable();
  outputProperties=new Properties();
}
 

Example 39

From project ANNIS, under directory /annis-gui/src/main/java/annis/gui/resultview/.

Source file: SingleResultPanel.java

  31 
vote

@Override public void attach(){
  try {
    if (wasAttached) {
      return;
    }
    wasAttached=true;
    ResolverEntry[] entries=resolverProvider.getResolverEntries(result);
    visualizers=new LinkedList<VisualizerPanel>();
    List<VisualizerPanel> openVisualizers=new LinkedList<VisualizerPanel>();
    token=result.getSDocumentGraph().getSortedSTokenByText();
    List<SNode> segNodes=CommonHelper.getSortedSegmentationNodes(segmentationName,result.getSDocumentGraph());
    markedAndCovered=calculateMarkedAndCoveredIDs(result,segNodes);
    calulcateColorsForMarkedAndCoverd();
    String resultID="" + new Random().nextInt(Integer.MAX_VALUE);
    for (int i=0; i < entries.length; i++) {
      int textNr=0;
      EList<STextualDS> allTexts=result.getSDocumentGraph().getSTextualDSs();
      for (      STextualDS text : allTexts) {
        String htmlID="resolver-" + resultNumber + "_"+ textNr+ "-"+ i;
        VisualizerPanel p=new VisualizerPanel(entries[i],result,token,visibleTokenAnnos,markedAndCovered,markedCoveredMap,markedExactMap,text,htmlID,resultID,this,segmentationName,ps,allTexts.size() > 1);
        visualizers.add(p);
        Properties mappings=entries[i].getMappings();
        if (Boolean.parseBoolean(mappings.getProperty(INITIAL_OPEN,"false"))) {
          openVisualizers.add(p);
        }
        textNr++;
      }
    }
    for (    VisualizerPanel p : visualizers) {
      addComponent(p);
    }
    for (    VisualizerPanel p : openVisualizers) {
      p.toggleVisualizer(true,null);
    }
  }
 catch (  Exception ex) {
    log.error("problems with initializing Visualizer Panel",ex);
  }
}
 

Example 40

From project android-aac-enc, under directory /src/com/coremedia/iso/.

Source file: PropertyBoxParserImpl.java

  30 
vote

public PropertyBoxParserImpl(String... customProperties){
  Context context=AACToM4A.getContext();
  InputStream raw=null, is=null;
  mapping=new Properties();
  try {
    raw=context.getResources().openRawResource(R.raw.isoparser);
    is=new BufferedInputStream(raw);
    mapping.load(is);
    Enumeration<URL> enumeration=Thread.currentThread().getContextClassLoader().getResources("isoparser-custom.properties");
    while (enumeration.hasMoreElements()) {
      URL url=enumeration.nextElement();
      InputStream customIS=new BufferedInputStream(url.openStream());
      try {
        mapping.load(customIS);
      }
  finally {
        customIS.close();
      }
    }
    for (    String customProperty : customProperties) {
      mapping.load(new BufferedInputStream(getClass().getResourceAsStream(customProperty)));
    }
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
 finally {
    try {
      if (raw != null)       raw.close();
      if (is != null)       is.close();
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}
 

Example 41

From project 3Dto2DApplet, under directory /src/java/nl/dannyarends/generic/.

Source file: Utils.java

  29 
vote

/** 
 * Creates a thread pool not queued with max number of threads defined in properties or DEF_MAX_POOLED_THREAD = 20
 * @param properties where property THREADSINPOOL gives max threads Note if THREADSINPOOL not integers, or negative then DEF_MAX_POOLED_THREAD used
 * @param threadfactory threadfactory to use
 */
public ThreadPool(Properties properties,ThreadFactory threadfactory){
  try {
    maxThreads=Integer.parseInt(properties.getProperty(MAXNOTHREAD));
    if (maxThreads < 0)     maxThreads=DEF_MAX_POOLED_THREAD;
  }
 catch (  Exception e) {
    maxThreads=DEF_MAX_POOLED_THREAD;
  }
  freeThreads=new ArrayList<PooledThread>(maxThreads);
  busyThreads=new HashMap<PooledThread,PooledThread>(maxThreads);
  this.threadFactory=threadfactory;
}
 

Example 42

From project android_8, under directory /src/com/google/gson/internal/.

Source file: $Gson$Types.java

  29 
vote

/** 
 * Returns a two element array containing this map's key and value types in positions 0 and 1 respectively.
 */
public static Type[] getMapKeyAndValueTypes(Type context,Class<?> contextRawType){
  if (context == Properties.class) {
    return new Type[]{String.class,String.class};
  }
  Type mapType=getSupertype(context,contextRawType,Map.class);
  ParameterizedType mapParameterizedType=(ParameterizedType)mapType;
  return mapParameterizedType.getActualTypeArguments();
}
 

Example 43

From project android_external_guava, under directory /src/com/google/common/collect/.

Source file: Maps.java

  29 
vote

/** 
 * Creates an  {@code ImmutableMap<String, String>} from a {@code Properties}instance. Properties normally derive from  {@code Map<Object, Object>}, but they typically contain strings, which is awkward. This method lets you get a plain-old- {@code Map} out of a {@code Properties}.
 * @param properties a {@code Properties} object to be converted
 * @return an immutable map containing all the entries in{@code properties}
 * @throws ClassCastException if any key in {@code Properties} is not a{@code String}
 * @throws NullPointerException if any key or value in {@code Properties} isnull.
 */
public static ImmutableMap<String,String> fromProperties(Properties properties){
  ImmutableMap.Builder<String,String> builder=ImmutableMap.builder();
  for (Enumeration<?> e=properties.propertyNames(); e.hasMoreElements(); ) {
    String key=(String)e.nextElement();
    builder.put(key,properties.getProperty(key));
  }
  return builder.build();
}