Ejemplo n.º 1
0
  public static void main(String[] args) throws MessagingException, IOException {
    IMAPFolder folder = null;
    Store store = null;
    String subject = null;
    Flag flag = null;
    try {
      Properties props = System.getProperties();
      props.setProperty("mail.store.protocol", "imaps");
      props.setProperty("mail.imap.host", "imap.googlemail.com");
      SimpleAuthenticator authenticator =
          new SimpleAuthenticator("*****@*****.**", "hhy8611hhyy");
      Session session = Session.getDefaultInstance(props, null);
      // Session session = Session.getDefaultInstance(props, authenticator);

      store = session.getStore("imaps");
      //          store.connect("imap.googlemail.com","*****@*****.**", "hhy8611hhyy");
      // store.connect("imap.googlemail.com","*****@*****.**", "hhy8611hhyy");

      store.connect("*****@*****.**", "hhy8611hhy");
      // folder = (IMAPFolder) store.getFolder("[Gmail]/Spam"); // This doesn't work for other email
      // account
      folder = (IMAPFolder) store.getFolder("inbox"); // This works for both email account

      if (!folder.isOpen()) folder.open(Folder.READ_WRITE);
      Message[] messages = messages = folder.getMessages(150, 150); // folder.getMessages();
      System.out.println("No of get Messages : " + messages.length);
      System.out.println("No of Messages : " + folder.getMessageCount());
      System.out.println("No of Unread Messages : " + folder.getUnreadMessageCount());
      System.out.println("No of New Messages : " + folder.getNewMessageCount());
      System.out.println(messages.length);
      for (int i = 0; i < messages.length; i++) {

        System.out.println(
            "*****************************************************************************");
        System.out.println("MESSAGE " + (i + 1) + ":");
        Message msg = messages[i];
        // System.out.println(msg.getMessageNumber());
        // Object String;
        // System.out.println(folder.getUID(msg)

        subject = msg.getSubject();

        System.out.println("Subject: " + subject);
        System.out.println("From: " + msg.getFrom()[0]);
        System.out.println("To: " + msg.getAllRecipients()[0]);
        System.out.println("Date: " + msg.getReceivedDate());
        System.out.println("Size: " + msg.getSize());
        System.out.println(msg.getFlags());
        System.out.println("Body: \n" + msg.getContent());
        System.out.println(msg.getContentType());
      }
    } finally {
      if (folder != null && folder.isOpen()) {
        folder.close(true);
      }
      if (store != null) {
        store.close();
      }
    }
  }
Ejemplo n.º 2
0
  public void setUp() throws Exception {
    super.setUp();
    theDaemon = getMockLockssDaemon();
    tempDir = getTempDir();
    String tempDirPath = tempDir.getAbsolutePath();
    System.setProperty("java.io.tmpdir", tempDirPath);

    Properties p = new Properties();
    p.setProperty(IdentityManager.PARAM_IDDB_DIR, tempDirPath + "iddb");
    p.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath);
    p.setProperty(IdentityManager.PARAM_LOCAL_IP, "127.0.0.1");
    p.setProperty(V3LcapMessage.PARAM_REPAIR_DATA_THRESHOLD, "4096");
    ConfigurationUtil.setCurrentConfigFromProps(p);
    IdentityManager idmgr = theDaemon.getIdentityManager();
    idmgr.startService();
    mPollMgr = new MockPollManager();
    theDaemon.setPollManager(mPollMgr);
    try {
      m_testID = idmgr.stringToPeerIdentity("127.0.0.1");
    } catch (IOException ex) {
      fail("can't open test host 127.0.0.1: " + ex);
    }
    m_repairProps = new CIProperties();
    m_repairProps.setProperty("key1", "val1");
    m_repairProps.setProperty("key2", "val2");
    m_repairProps.setProperty("key3", "val3");

    m_testVoteBlocks = V3TestUtils.makeVoteBlockList(10);
    m_testMsg = this.makeTestVoteMessage(m_testVoteBlocks);
  }
Ejemplo n.º 3
0
    /**
     * Parse the parameters of a connection into a CoreNLP properties file that can be passed into
     * {@link StanfordCoreNLP}, and used in the I/O stages.
     *
     * @param httpExchange The http exchange; effectively, the request information.
     * @return A {@link Properties} object corresponding to a combination of default and passed
     *     properties.
     * @throws UnsupportedEncodingException Thrown if we could not decode the key/value pairs with
     *     UTF-8.
     */
    private Properties getProperties(HttpExchange httpExchange)
        throws UnsupportedEncodingException {
      // Load the default properties
      Properties props = new Properties();
      defaultProps
          .entrySet()
          .stream()
          .forEach(
              entry -> props.setProperty(entry.getKey().toString(), entry.getValue().toString()));

      // Try to get more properties from query string.
      Map<String, String> urlParams = getURLParams(httpExchange.getRequestURI());
      if (urlParams.containsKey("properties")) {
        StringUtils.decodeMap(URLDecoder.decode(urlParams.get("properties"), "UTF-8"))
            .entrySet()
            .forEach(entry -> props.setProperty(entry.getKey(), entry.getValue()));
      } else if (urlParams.containsKey("props")) {
        StringUtils.decodeMap(URLDecoder.decode(urlParams.get("properties"), "UTF-8"))
            .entrySet()
            .forEach(entry -> props.setProperty(entry.getKey(), entry.getValue()));
      }

      // Make sure the properties compile
      props.setProperty(
          "annotators",
          StanfordCoreNLP.ensurePrerequisiteAnnotators(
              props.getProperty("annotators").split("[, \t]+")));

      return props;
    }
  public void setUp() throws Exception {
    super.setUp();
    tempDirPath = getTempDir().getAbsolutePath() + File.separator;

    theDaemon = getMockLockssDaemon();
    theDaemon.getAlertManager();
    theDaemon.getPluginManager().setLoadablePluginsReady(true);
    theDaemon.getHashService();
    MockSystemMetrics metrics = new MyMockSystemMetrics();
    metrics.initService(theDaemon);
    theDaemon.setSystemMetrics(metrics);

    theDaemon.setDaemonInited(true);

    Properties props = new Properties();
    props.setProperty(SystemMetrics.PARAM_HASH_TEST_DURATION, "1000");
    props.setProperty(SystemMetrics.PARAM_HASH_TEST_BYTE_STEP, "1024");
    props.setProperty(ConfigManager.PARAM_PLATFORM_DISK_SPACE_LIST, tempDirPath);
    ConfigurationUtil.setCurrentConfigFromProps(props);

    pluginMgr = theDaemon.getPluginManager();
    pluginMgr.startService();
    theDaemon.getHashService().startService();
    metrics.startService();
    metrics.setHashSpeed(100);

    simPlugin = PluginTestUtil.findPlugin(SimulatedPlugin.class);
  }
Ejemplo n.º 5
0
  public static void testEnum() throws Exception {
    Builder b = new Builder();
    b.addClasspath(new File("bin"));
    b.setProperty("Export-Package", "test.metatype");
    b.setProperty("-metatype", "*");
    b.build();
    assertEquals(0, b.getErrors().size());
    assertEquals(0, b.getWarnings().size());

    Resource r = b.getJar().getResource("OSGI-INF/metatype/test.metatype.MetatypeTest$Enums.xml");
    IO.copy(r.openInputStream(), System.err);

    Document d = db.parse(r.openInputStream());
    assertEquals(
        "http://www.osgi.org/xmlns/metatype/v1.1.0", d.getDocumentElement().getNamespaceURI());

    Properties p = new Properties();
    p.setProperty("r", "requireConfiguration");
    p.setProperty("i", "ignoreConfiguration");
    p.setProperty("o", "optionalConfiguration");
    Enums enums = Configurable.createConfigurable(Enums.class, (Map<Object, Object>) p);
    assertEquals(Enums.X.requireConfiguration, enums.r());
    assertEquals(Enums.X.ignoreConfiguration, enums.i());
    assertEquals(Enums.X.optionalConfiguration, enums.o());
  }
Ejemplo n.º 6
0
 // Save window location in appSettings hash table
 private void saveShellBounds() {
   // Save window bounds in app settings
   Rectangle bounds = getShell().getBounds();
   appSettings.setProperty("top", String.valueOf(bounds.y));
   appSettings.setProperty("left", String.valueOf(bounds.x));
   appSettings.setProperty("width", String.valueOf(bounds.width));
   appSettings.setProperty("height", String.valueOf(bounds.height));
 }
Ejemplo n.º 7
0
 private Properties getProperties() {
   Properties props = new Properties();
   props.setProperty("resource.loader", "class");
   props.setProperty(
       "class.resource.loader.class",
       "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
   return props;
 }
Ejemplo n.º 8
0
  /**
   * Creates a new instance of SavedConfiguration. There should only ever be one instance of this
   * class (a Singleton), so we have made it private.
   */
  private SavedConfiguration() {
    parameters = loadParametersFromFile();

    if (parameters == null) {
      parameters = new Properties();

      parameters.setProperty(SERVER_ADDRESS, "localhost");
      parameters.setProperty(SERVER_PORT, "" + java.rmi.registry.Registry.REGISTRY_PORT);
    }
  }
Ejemplo n.º 9
0
 // Get and initialize the DICOM Storage SCP
 private static DicomStorageScp getDicomStore() {
   String aetitle, port;
   Properties p = new Properties();
   aetitle = TrialConfig.getDicomStoreAETitle();
   port = TrialConfig.getDicomStorePort();
   p.setProperty("storage-scp-aet", aetitle);
   p.setProperty("port", port);
   p.setProperty("dest", TrialConfig.basepath + TrialConfig.dicomStoreDir);
   Dicom.initialize(p);
   return Dicom.getStorageScp();
 }
Ejemplo n.º 10
0
  public void save() {
    final Properties properties = new Properties();
    Optional.ofNullable(username).ifPresent(s -> properties.setProperty("username", s));
    Optional.ofNullable(password).ifPresent(s -> properties.setProperty("password", s));
    Optional.ofNullable(from)
        .ifPresent(d -> properties.setProperty("from", d.format(DateTimeFormatter.ISO_DATE)));

    try {
      properties.store(getConfigurationWriter(), null);
    } catch (IOException e) {
      e.printStackTrace(); // TODO logging
    }
  }
  /**
   * Serialize an XML document (DOM tree).
   *
   * @param out the output stream to write to
   * @param document the XML document
   * @exception IOException
   */
  public static void write(OutputStream out, Document document)
      throws IOException, TransformerConfigurationException, TransformerException {

    DOMSource source = new DOMSource(document);
    StreamResult result = new StreamResult(out);
    Transformer transformer = TransformerFactory.newInstance().newTransformer();
    Properties outputProperties = new Properties();
    outputProperties.setProperty(OutputKeys.METHOD, "xml");
    outputProperties.setProperty(OutputKeys.INDENT, "yes");
    outputProperties.setProperty(OutputKeys.ENCODING, "UTF-8"); // the default anyway
    transformer.setOutputProperties(outputProperties);
    transformer.transform(source, result);
  }
Ejemplo n.º 12
0
 public static void main(String[] args) throws Exception {
   Properties props = new Properties();
   // 向Properties中增加属性
   props.setProperty("username", "yeeku");
   props.setProperty("password", "123456");
   // 将Properties中的属性保存到a.ini文件中
   props.store(new FileOutputStream("a.ini"), "comment line");
   // 新建一个Properties对象
   Properties props2 = new Properties();
   // 向Properties中增加属性
   props2.setProperty("gender", "male");
   // 将a.ini文件中的属性名-属性值追加到props2中
   props2.load(new FileInputStream("a.ini"));
   System.out.println(props2);
 }
  private static File dumpModulesPaths(@NotNull Project project) throws IOException {
    ApplicationManager.getApplication().assertReadAccessAllowed();

    Properties res = new Properties();

    MavenProjectsManager manager = MavenProjectsManager.getInstance(project);

    for (Module module : ModuleManager.getInstance(project).getModules()) {
      if (manager.isMavenizedModule(module)) {
        MavenProject mavenProject = manager.findProject(module);
        if (mavenProject != null && !manager.isIgnored(mavenProject)) {
          res.setProperty(
              mavenProject.getMavenId().getGroupId()
                  + ':'
                  + mavenProject.getMavenId().getArtifactId()
                  + ":pom"
                  + ':'
                  + mavenProject.getMavenId().getVersion(),
              mavenProject.getFile().getPath());

          res.setProperty(
              mavenProject.getMavenId().getGroupId()
                  + ':'
                  + mavenProject.getMavenId().getArtifactId()
                  + ':'
                  + mavenProject.getPackaging()
                  + ':'
                  + mavenProject.getMavenId().getVersion(),
              mavenProject.getOutputDirectory());
        }
      }
    }

    File file =
        new File(
            PathManager.getSystemPath(),
            "Maven/idea-projects-state-" + project.getLocationHash() + ".properties");
    file.getParentFile().mkdirs();

    OutputStream out = new BufferedOutputStream(new FileOutputStream(file));
    try {
      res.store(out, null);
    } finally {
      out.close();
    }

    return file;
  }
Ejemplo n.º 14
0
  protected Properties convertProperties(Map<String, Object> m) {
    Properties res = null;

    {
      if (m != null) {
        res = new Properties();

        Set<String> keys = m.keySet();
        for (String key : keys) {
          String value = null;

          // Set 'value':
          {
            Object o = m.get(key);
            if (o != null) {
              value = o.toString();
            }
          }

          res.setProperty(key, value);
        }
      }
    }

    return res;
  }
Ejemplo n.º 15
0
  private void loadLanguage(Properties par1Properties, String par2Str) throws IOException {
    BufferedReader bufferedreader =
        new BufferedReader(
            new InputStreamReader(
                (net.minecraft.src.StringTranslate.class)
                    .getResourceAsStream(
                        (new StringBuilder())
                            .append("/lang/")
                            .append(par2Str)
                            .append(".lang")
                            .toString()),
                "UTF-8"));

    for (String s = bufferedreader.readLine(); s != null; s = bufferedreader.readLine()) {
      s = s.trim();

      if (s.startsWith("#")) {
        continue;
      }

      String as[] = s.split("=");

      if (as != null && as.length == 2) {
        par1Properties.setProperty(as[0], as[1]);
      }
    }
  }
Ejemplo n.º 16
0
 private void setProperty(String key, String value) {
   if (value != null) {
     properties.setProperty(key, value);
   } else {
     properties.remove(key);
   }
 }
 public static void init() throws Exception {
   Properties props = new Properties();
   int pid = OSProcess.getId();
   String path = File.createTempFile("dunit-cachejta_", ".xml").getAbsolutePath();
   /** * Return file as string and then modify the string accordingly ** */
   String file_as_str = readFile(TestUtil.getResourcePath(CacheUtils.class, "cachejta.xml"));
   file_as_str = file_as_str.replaceAll("newDB", "newDB_" + pid);
   String modified_file_str = modifyFile(file_as_str);
   FileOutputStream fos = new FileOutputStream(path);
   BufferedWriter wr = new BufferedWriter(new OutputStreamWriter(fos));
   wr.write(modified_file_str);
   wr.flush();
   wr.close();
   props.setProperty("cache-xml-file", path);
   //    String tableName = "";
   //		  props.setProperty("mcast-port", "10339");
   try {
     //			   ds = DistributedSystem.connect(props);
     ds = (new ExceptionsDUnitTest("temp")).getSystem(props);
     cache = CacheFactory.create(ds);
   } catch (Exception e) {
     e.printStackTrace(System.err);
     throw new Exception("" + e);
   }
 }
Ejemplo n.º 18
0
 private boolean testExecutionMode() {
   executionMode = false;
   JarFile file = null;
   try {
     file = new JarFile(getTangaraPath());
     ZipEntry entry = file.getEntry(EXECUTION_PROPERTIES_FILENAME);
     if (entry != null) {
       executionMode = true;
       System.out.println("execution mode detected");
       Properties executionProperties = new Properties();
       InputStream ips = ClassLoader.getSystemResourceAsStream(EXECUTION_PROPERTIES_FILENAME);
       executionProperties.load(ips);
       if (executionProperties.containsKey("main-program")) {
         String mainTangaraFile = executionProperties.getProperty("main-program");
         System.out.println("main tangara file: " + mainTangaraFile);
         properties.setProperty("main-program", mainTangaraFile);
       } else {
         System.err.println("error : main program not specified");
       }
       if (executionProperties.containsKey("language")) {
         String language = executionProperties.getProperty("language");
         properties.setProperty("language", language);
         System.out.println("language: " + language);
       } else {
         System.err.println("error : language not specified");
       }
       if (executionProperties.containsKey("resources")) {
         String resources = executionProperties.getProperty("resources");
         properties.setProperty("program.resources", resources);
         System.out.println("resources: " + resources);
       } else {
         System.err.println("error : resources not specified");
       }
     }
   } catch (IOException e) {
     e.printStackTrace();
   } finally {
     if (file != null) {
       try {
         file.close();
       } catch (IOException e) {
         System.err.println("error while closing tangara JAR file");
       }
     }
   }
   return executionMode;
 }
Ejemplo n.º 19
0
 public static void copySystemProperties(Properties configProps) {
   for (Enumeration e = System.getProperties().propertyNames(); e.hasMoreElements(); ) {
     String key = (String) e.nextElement();
     if (key.startsWith("felix.") || key.startsWith("org.osgi.framework.")) {
       configProps.setProperty(key, System.getProperty(key));
     }
   }
 }
Ejemplo n.º 20
0
 /**
  * Return the request parameters as a Properties. Only the first value of multivalued parameters
  * is included.
  */
 Properties getParamsAsProps() {
   Properties props = new Properties();
   for (Enumeration en = req.getParameterNames(); en.hasMoreElements(); ) {
     String name = (String) en.nextElement();
     props.setProperty(name, req.getParameter(name));
   }
   return props;
 }
 /** Property keys converted to all uppercase. */
 private boolean parseProperty(String line, Properties properties) {
   final int index = line.indexOf(':');
   if (index < 0) return false;
   final String key = line.substring(0, index).trim();
   final String value = line.substring(index + 1).trim();
   properties.setProperty(key.toUpperCase(), value);
   return true;
 }
  public void testSkipsScriptTagsSpansRing() throws IOException {
    Properties p = new Properties();
    p.setProperty(GoslingHtmlLinkExtractor.PARAM_BUFFER_CAPACITY, "90");
    ConfigurationUtil.setCurrentConfigFromProps(p);
    extractor = new GoslingHtmlLinkExtractor();

    doScriptSkipTest("<script>", "</script>");
  }
Ejemplo n.º 23
0
  private synchronized void save() {
    myDir.mkdirs();

    Properties props = new Properties();

    props.setProperty(KIND_KEY, myKind.toString());
    props.setProperty(ID_KEY, myRepositoryId);
    props.setProperty(PATH_OR_URL_KEY, myRepositoryPathOrUrl);
    props.setProperty(INDEX_VERSION_KEY, CURRENT_VERSION);
    if (myUpdateTimestamp != null)
      props.setProperty(TIMESTAMP_KEY, String.valueOf(myUpdateTimestamp));
    if (myDataDirName != null) props.setProperty(DATA_DIR_NAME_KEY, myDataDirName);
    if (myFailureMessage != null) props.setProperty(FAILURE_MESSAGE_KEY, myFailureMessage);

    try {
      FileOutputStream s = new FileOutputStream(new File(myDir, INDEX_INFO_FILE));
      try {
        props.store(s, null);
      } finally {
        s.close();
      }
    } catch (IOException e) {
      MavenLog.LOG.warn(e);
    }
  }
 public static void save(Map<String, String> map, File file) throws IOException {
   Assert.notNull(map, "属性集合为空!");
   Properties properties = new Properties();
   Set<Map.Entry<String, String>> entries = map.entrySet();
   for (Map.Entry<String, String> entry : entries) {
     String key = entry.getKey();
     String value = entry.getValue();
     properties.setProperty(key, value);
   }
   save(properties, file);
 }
Ejemplo n.º 25
0
  /**
   * Creates configuration properties object for new connection.
   *
   * <p>See GridGain client javadoc for more information: {@link GridClientConfiguration}.
   *
   * <p>All parameters are optional.
   *
   * @return Configuration.
   */
  private static Properties configuration() {
    Properties cfg = new Properties();

    // Node ID where to execute query. This property is useful when you have several
    // local caches with same name in topology and want to specify which of them to connect.
    //
    // Uncomment line below and provide correct ID if needed.
    //        cfg.setProperty(CONF_NODE_ID, "E0869485-512C-41F9-866D-BE906B591BEA");

    // Communication protocol (TCP or HTTP). Default is TCP.
    cfg.setProperty(CONF_PROTO, "TCP");

    // Socket timeout. Default is 0 which means infinite timeout.
    cfg.setProperty(CONF_TIMEOUT, "0");

    // Flag indicating whether TCP_NODELAY flag should be enabled for outgoing
    // connections. Default is true.
    cfg.setProperty(CONF_TCP_NO_DELAY, "true");

    // Flag indicating that SSL is needed for connection. Default is false.
    cfg.setProperty(CONF_SSL_ENABLED, "false");

    // SSL context factory class name. Class must extend
    // org.gridgain.client.ssl.GridSslContextFactory
    // interface, have default constructor and be available on classpath.
    // Ignored if SSL is disabled.
    cfg.setProperty(CONF_SSL_FACTORY, "org.gridgain.client.ssl.GridSslBasicContextFactory");

    // SSL pass-phrase.
    // Ignored is SSL is disabled.
    cfg.setProperty(CONF_CREDS, "s3cr3t");

    // Flag indicating that topology is cached internally. Cache will be refreshed
    // in the background with interval defined by CONF_TOP_REFRESH_FREQ property
    // (see below). Default is false.
    cfg.setProperty(CONF_TOP_CACHE_ENABLED, "false");

    // Topology cache refresh frequency. Default is 2000 ms.
    cfg.setProperty(CONF_TOP_REFRESH_FREQ, "2000");

    // Maximum amount of time that connection can be idle before it is closed.
    // Default is 30000 ms.
    cfg.setProperty(CONF_MAX_IDLE_TIME, "30000");

    return cfg;
  }
Ejemplo n.º 26
0
  @Override
  protected void writePlans(String dir) {
    Properties p = new Properties();
    p.setProperty("resource.loader", "class");
    p.setProperty(
        "class.resource.loader.class",
        "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

    Velocity.init(p);
    Context context = new VelocityContext();
    context.put("plans", plans);

    Template template = Velocity.getTemplate("pl/poznan/put/transims/demand/matsim/plans.xml.vm");
    File planFile = new File(dir + "\\plans.xml");

    try (Writer writer = new BufferedWriter(new FileWriter(planFile))) {
      template.merge(context, writer);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
  public static void ChineseSegment(String fullName, String segName) throws Exception {

    System.setOut(new PrintStream(new FileOutputStream(new File(segName))));
    String filename = fullName;

    // setting property
    Properties props = new Properties();
    props.setProperty(
        "sighanCorporaDict", "C:/Users/Xin/Documents/NetBeansProjects/BleuTranslator/data");
    props.setProperty(
        "serDictionary",
        "C:/Users/Xin/Documents/NetBeansProjects/BleuTranslator/data/dict-chris6.ser.gz");
    props.setProperty("testFile", filename);
    props.setProperty("inputEncoding", "UTF-8");
    props.setProperty("sighanPostProcessing", "true");

    CRFClassifier<CoreLabel> segmenter = new CRFClassifier<CoreLabel>(props);
    segmenter.loadClassifierNoExceptions(
        "C:/Users/Xin/Documents/NetBeansProjects/BleuTranslator/data/ctb.gz", props);
    segmenter.classifyAndWriteAnswers(filename);
  }
Ejemplo n.º 28
0
 /**
  * When launching a secondary runtime workbench, all projects already in dev mode must continue in
  * dev mode such that their class files are found.
  *
  * @param properties dev.properties
  */
 public static void weaveDevProperties(Properties properties) {
   if (fgIsDev) {
     Properties devProperties = getDevProperties();
     if (devProperties != null) {
       Set<?> entries = devProperties.entrySet();
       Iterator<?> iterator = entries.iterator();
       while (iterator.hasNext()) {
         Entry<?, ?> entry = (Entry<?, ?>) iterator.next();
         properties.setProperty((String) entry.getKey(), (String) entry.getValue());
       }
     }
   }
 }
Ejemplo n.º 29
0
  // TODO jz: log4j.properties should be used instead
  private static void configureLog4J(Properties properties) {
    // TODO Add a file appender for the logs
    // TODO Need to create a property in the properties file for it.
    // sgroschupf, 25Feb2008: this method will be obsolete with PIG-115.

    String log4jconf = properties.getProperty(LOG4J_CONF);
    String trueString = "true";
    boolean brief = trueString.equalsIgnoreCase(properties.getProperty(BRIEF));
    Level logLevel = Level.INFO;

    String logLevelString = properties.getProperty(DEBUG);
    if (logLevelString != null) {
      logLevel = Level.toLevel(logLevelString, Level.INFO);
    }

    if (log4jconf != null) {
      PropertyConfigurator.configure(log4jconf);
    } else if (!brief) {
      // non-brief logging - timestamps
      Properties props = new Properties();
      props.setProperty("log4j.rootLogger", "INFO, PIGCONSOLE");
      props.setProperty("log4j.appender.PIGCONSOLE", "org.apache.log4j.ConsoleAppender");
      props.setProperty("log4j.appender.PIGCONSOLE.layout", "org.apache.log4j.PatternLayout");
      props.setProperty(
          "log4j.appender.PIGCONSOLE.layout.ConversionPattern", "%d [%t] %-5p %c - %m%n");
      props.setProperty("log4j.appender.PIGCONSOLE.target", "System.err");
      PropertyConfigurator.configure(props);
    } else {
      // brief logging - no timestamps
      Properties props = new Properties();
      props.setProperty("log4j.rootLogger", "INFO, PIGCONSOLE");
      props.setProperty("log4j.appender.PIGCONSOLE", "org.apache.log4j.ConsoleAppender");
      props.setProperty("log4j.appender.PIGCONSOLE.layout", "org.apache.log4j.PatternLayout");
      props.setProperty("log4j.appender.PIGCONSOLE.layout.ConversionPattern", "%m%n");
      props.setProperty("log4j.appender.PIGCONSOLE.target", "System.err");
      PropertyConfigurator.configure(props);
    }
  }
Ejemplo n.º 30
0
  private void speichern(Path saveName) {
    Properties prop = new Properties();

    if (!quellListModel.isEmpty())
      for (int i = 0; i < quellListModel.getSize(); i++)
        prop.setProperty(
            String.format("quellMenu%d", i),
            quellListModel.getElementAt(i).getValueMember().toString());

    if (!zielListModel.isEmpty())
      for (int i = 0; i < zielListModel.getSize(); i++)
        prop.setProperty(
            String.format("zielMenu%d", i),
            zielListModel.getElementAt(i).getValueMember().toString());

    try {
      FileOutputStream out = new FileOutputStream(saveName.toString());
      prop.store(out, null);
      out.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }