当前位置: 首页>>代码示例>>C#>>正文


C# Properties.load方法代码示例

本文整理汇总了C#中Properties.load方法的典型用法代码示例。如果您正苦于以下问题:C# Properties.load方法的具体用法?C# Properties.load怎么用?C# Properties.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Properties的用法示例。


在下文中一共展示了Properties.load方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetProperties

        private static Properties SetProperties()
        {
            const string mzTabProperties = "conf/mztab/mztab.properties";
            const string formatProperties = "conf/mztab/mztab_format_error.properties";
            const string logicalProperties = "conf/mztab/mztab_logical_error.properties";
            const string crosscheckProperties = "conf/mztab/mztab_crosscheck_error.properties";
            try{
                properties = new Properties();
                StreamReader reader = new StreamReader(mzTabProperties);
                properties.load(reader);
                reader.Close();

                reader = new StreamReader(formatProperties);
                properties.load(reader);
                reader.Close();

                reader = new StreamReader(logicalProperties);
                properties.load(reader);
                reader.Close();

                reader = new StreamReader(crosscheckProperties);
                properties.load(reader);
                reader.Close();

                return properties;
            }
            catch (FileNotFoundException e){
                Console.Error.WriteLine(e.Message);
            }
            catch (IOException e){
                Console.Error.WriteLine(e.Message);
            }

            return null;
        }
开发者ID:neuhauser,项目名称:perseus-plugins,代码行数:35,代码来源:MZTabProperties.cs

示例2: loadProperties

 /**
  * This method loads a property file that may reside in the user space, or
  * in the classpath
  *
  * @param file
  *            the file to load
  * @param defaultProps a set of default properties
  * @return the Properties from the file; if it could not be processed, the defaultProps are returned.
  */
 public static Properties loadProperties(String file, Properties defaultProps)
 {
     Properties p = new Properties(defaultProps);
     InputStream ins = null;
     try
     {
         File f = new File(file);
         ins = new FileInputStream(f);
         p.load(ins);
     }
     catch (IOException e)
     {
         //try
         //{
         //    sealed URL resource = NetMeterUtils.class.getClassLoader().getResource(file);
         //    if (resource == null)
         //    {
         //        //log.warn("Cannot find " + file);
         //        return defaultProps;
         //    }
         //    ins = resource.openStream();
         //    if (ins == null)
         //    {
         //        log.warn("Cannot open " + file);
         //        return defaultProps;
         //    }
         //    p.load(ins);
         //}
         //catch (IOException ex)
         //{
         //    log.warn("Error reading " + file + " " + ex.toString());
         //    return defaultProps;
         //}
     }
     finally
     {
         JOrphanUtils.closeQuietly(ins);
     }
     return p;
 }
开发者ID:RalphC,项目名称:NetMeter,代码行数:49,代码来源:NetMeterUtils.cs

示例3: loadJMeterProperties

 /**
  * Load the JMeter properties file; if not found, then
  * default to "org/apache/jmeter/jmeter.properties" from the classpath
  *
  * c.f. loadProperties
  *
  */
 public static void loadJMeterProperties(String file)
 {
     Properties p = new Properties(System.getProperties());
     InputStream ins = null;
     try
     {
         File f = new File(file);
         ins = new FileInputStream(f);
         p.load(ins);
     }
     catch (IOException e)
     {
         try
         {
             ins = ClassLoader.getSystemResourceAsStream("org/apache/jmeter/jmeter.properties"); // $NON-NLS-1$
             if (ins == null)
             {
                 //throw new RuntimeException("Could not read JMeter properties file");
             }
             p.load(ins);
         }
         catch (IOException ex)
         {
             // JMeter.fail("Could not read internal resource. " +
             // "Archive is broken.");
         }
     }
     finally
     {
         JOrphanUtils.closeQuietly(ins);
     }
     appProperties = p;
 }
开发者ID:RalphC,项目名称:NetMeter,代码行数:40,代码来源:NetMeterUtils.cs

示例4: loadProperties

 public static Properties loadProperties() 
 {
     Properties nameMap = new Properties();
     FileInputStream fis = null;
     try 
     {
         fis = new FileInputStream(JMeterUtils.getJMeterHome()
                      + JMeterUtils.getPropDefault(SAVESERVICE_PROPERTIES, SAVESERVICE_PROPERTIES_FILE));
         nameMap.load(fis);
     } 
     finally
     {
         JOrphanUtils.closeQuietly(fis);
     }
     return nameMap;
 }
开发者ID:RalphC,项目名称:NetMeter,代码行数:16,代码来源:IOService.cs


注:本文中的Properties.load方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。