Java Code Examples for java.util.Properties#list()

The following examples show how to use java.util.Properties#list() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: mcaselector   File: Debug.java    License: MIT License 6 votes vote down vote up
public static void initLogWriter() {
	if (logWriter == null) {
		logWriter = new LogWriter();
	}

	Properties sysProps = System.getProperties();
	sysProps.list(System.out);

	Debug.dumpf("os.name:                      %s", System.getProperty("os.name"));
	Debug.dumpf("os.version:                   %s", System.getProperty("os.version"));
	Debug.dumpf("user.dir:                     %s", System.getProperty("user.dir"));
	Debug.dumpf("cache.dir:                    %s", Config.DEFAULT_BASE_CACHE_DIR.getAbsolutePath());
	Debug.dumpf("proc.cores:                   %s", Runtime.getRuntime().availableProcessors());
	Debug.dumpf("java.version:                 %s", System.getProperty("java.version"));
	Debug.dumpf("java.vm.specification.vendor: %s", System.getProperty("java.vm.specification.vendor"));
	Debug.dumpf("jvm.max.mem:                  %d", Runtime.getRuntime().maxMemory());
}
 
Example 2
/**
 * Get Net Server information
 *
 * @return system information for the Network Server
 */
private String getNetSysInfo() 
{
	StringBuilder sysinfo = new StringBuilder();
	LocalizedResource localLangUtil = langUtil;
	if (currentSession != null && currentSession.langUtil != null)
	localLangUtil = currentSession.langUtil;
	sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBanner.I")+ "\n");
	sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoVersion.I")+ " " + att_srvrlslv);
	sysinfo.append("  ");
	sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBuild.I")+ " " + buildNumber);
	sysinfo.append("  ");
	sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoDrdaPRDID.I")+ " " + prdId);
	if (SanityManager.DEBUG)
	{
		sysinfo.append("  ** SANE BUILD **");
	}
	sysinfo.append("\n");
	// add property information
	Properties p = getPropertyValues();
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	PrintStream ps =  new PrintStream(bos);
	p.list(ps);
	sysinfo.append(bos.toString());
	return sysinfo.toString();
}
 
Example 3
private static Args parseArgs(String[] args) throws IOException {
  Iterator<String> i = Arrays.asList(args).iterator();
  Args result = new Args();
  result.connectionString = i.next();
  result.dcpMessageCount = Integer.parseInt(i.next());
  File configFile = new File(i.next());
  if (i.hasNext()) {
    result.collectionString = i.next();
    System.out.println("Target Collections: " + result.collectionString);
  }

  Properties props = new Properties();
  props.load(new FileInputStream(configFile));
  result.settings = props;

  System.out.println("Configuration properties read from " + configFile.getAbsolutePath());
  props.list(System.out);
  System.out.println();

  return result;
}
 
Example 4
/**
 * Get Net Server information
 *
 * @return system information for the Network Server
 */
private String getNetSysInfo() 
{
	StringBuilder sysinfo = new StringBuilder();
	LocalizedResource localLangUtil = langUtil;
	if (currentSession != null && currentSession.langUtil != null)
	localLangUtil = currentSession.langUtil;
	sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBanner.I")+ "\n");
	sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoVersion.I")+ " " + att_srvrlslv);
	sysinfo.append("  ");
	sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoBuild.I")+ " " + buildNumber);
	sysinfo.append("  ");
	sysinfo.append(localLangUtil.getTextMessage("DRDA_SysInfoDrdaPRDID.I")+ " " + prdId);
	if (SanityManager.DEBUG)
	{
		sysinfo.append("  ** SANE BUILD **");
	}
	sysinfo.append("\n");
	// add property information
	Properties p = getPropertyValues();
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	PrintStream ps =  new PrintStream(bos);
	p.list(ps);
	sysinfo.append(bos.toString());
	return sysinfo.toString();
}
 
Example 5
@Override
public void doGet(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {
  if (req.getParameter("testing") != null) {
    resp.setContentType("text/plain");
    resp.getWriter().println("Hello, this is a testing servlet. \n\n");
    Properties p = System.getProperties();
    p.list(resp.getWriter());

  } else {
    UserService userService = UserServiceFactory.getUserService();
    User currentUser = userService.getCurrentUser();

    if (currentUser != null) {
      resp.setContentType("text/plain");
      resp.getWriter().println("Hello, " + currentUser.getNickname());
    } else {
      resp.sendRedirect(userService.createLoginURL(req.getRequestURI()));
    }
  }
}
 
Example 6
Source Project: keycloak   File: ProfileTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void configWithPropertiesFile() throws IOException {
    Assert.assertEquals("community", Profile.getName());
    Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.DOCKER));
    Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.IMPERSONATION));
    Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.UPLOAD_SCRIPTS));

    File d = temporaryFolder.newFolder();
    File f = new File(d, "profile.properties");

    Properties p = new Properties();
    p.setProperty("profile", "preview");
    p.setProperty("feature.docker", "enabled");
    p.setProperty("feature.impersonation", "disabled");
    p.setProperty("feature.upload_scripts", "enabled");
    PrintWriter pw = new PrintWriter(f);
    p.list(pw);
    pw.close();

    System.setProperty("jboss.server.config.dir", d.getAbsolutePath());

    Profile.init();

    Assert.assertEquals("preview", Profile.getName());
    Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.DOCKER));
    Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.OPENSHIFT_INTEGRATION));
    Assert.assertFalse(Profile.isFeatureEnabled(Profile.Feature.IMPERSONATION));
    Assert.assertTrue(Profile.isFeatureEnabled(Profile.Feature.UPLOAD_SCRIPTS));

    System.getProperties().remove("jboss.server.config.dir");

    Profile.init();
}
 
Example 7
@Bean
public static PropertySourcesPlaceholderConfigurer propConfig() {
    Properties properties = new Properties();
    properties.put("alfio.version", "2.0-SNAPSHOT");
    properties.put("alfio.build-ts", ZonedDateTime.now(ZoneId.of("UTC")).minusDays(1).toString());
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(out);
    properties.list(pw);
    pw.flush();
    var configurer =  new PropertySourcesPlaceholderConfigurer();
    configurer.setLocation(new ByteArrayResource(out.toByteArray()));
    return configurer;
}
 
Example 8
Source Project: netbeans   File: RunnerHttp.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Get extra properties for ZIP entries.
 * <p/>
 * @return Extra properties for ZIP entries.
 */
byte[] getExtraProperties() {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Properties props = new Properties();
    props.setProperty("data-request-type", "file-xfer");
    props.setProperty("last-modified", getLastModified());
    props.put("data-request-name", "DEFAULT");
    props.put("data-request-is-recursive", "true");
    props.put("Content-Type", "application/octet-stream");
    props.list(new java.io.PrintStream(baos));
    return baos.toByteArray();
}
 
Example 9
/**
 * Transform porperties (key-value) separate by lineSeparator
 * @param properties
 * @return String with values
 */
public String transform(Properties properties) {

    StringWriter    writer = new StringWriter();
    properties.list(new PrintWriter(writer));
    return deleteHeaderLine(writer.getBuffer().toString());
}
 
Example 10
Source Project: testgrid   File: AMIMapper.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Generate a string which include all the properties (key and the value).
 *
 * @param properties Properties
 * @return List of properties (key and value) as a String
 */
private String getPropertiesAsString(Properties properties) {
    if (properties.isEmpty()) {
        return "Empty property-list.";
    } else {
        StringWriter writer = new StringWriter();
        properties.list(new PrintWriter(writer));
        return writer.getBuffer().toString();
    }
}
 
Example 11
public static void main (String args[]) throws Exception
{
	try
	{
		NetworkServerControl server = new NetworkServerControl();
		Properties p = server.getCurrentProperties();
		p.list(System.out);
		ij.getPropertyArg(args); 

		// create a connection in a different thread
		startConnection();
		// wait for connection
		joinwait();
		//server.setLogWriter(System.out);
		// set tracing on for the waiting connection
		server.trace(3, true);
		//test NetworkServerControl.logConnections
		server.logConnections(true);
		// get properties
		System.out.println("Properties with tracing on");
		p = server.getCurrentProperties();
		p.list(System.out);
		// set tracing on for all connections
		server.trace(true);
		//test NetworkServerControl.setTraceDirectory
		server.setTraceDirectory(DERBY_SYSTEM_HOME);
		// get properties
		System.out.println("Properties with tracing on");
		p = server.getCurrentProperties();
		p.list(System.out);
		joinsignal();
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
}
 
Example 12
Source Project: pulsar   File: ServiceConfigurationTest.java    License: Apache License 2.0 5 votes vote down vote up
private InputStream updateProp(String zookeeperServer, String brokerServicePort, String namespace)
        throws IOException {
    checkNotNull(fileName);
    Properties properties = new Properties();
    InputStream stream = this.getClass().getClassLoader().getResourceAsStream(fileName);
    properties.load(stream);
    properties.setProperty("zookeeperServers", zookeeperServer);
    properties.setProperty("brokerServicePort", brokerServicePort);
    if (namespace != null)
        properties.setProperty("bootstrapNamespaces", namespace);
    StringWriter writer = new StringWriter();
    properties.list(new PrintWriter(writer));
    return new ByteArrayInputStream(writer.toString().getBytes(StandardCharsets.UTF_8));
}
 
Example 13
public static void main (String args[]) throws Exception
{
	try
	{
		NetworkServerControl server = new NetworkServerControl();
		Properties p = server.getCurrentProperties();
		p.list(System.out);
		ij.getPropertyArg(args); 

		// create a connection in a different thread
		startConnection();
		// wait for connection
		joinwait();
		//server.setLogWriter(System.out);
		// set tracing on for the waiting connection
		server.trace(3, true);
		//test NetworkServerControl.logConnections
		server.logConnections(true);
		// get properties
		System.out.println("Properties with tracing on");
		p = server.getCurrentProperties();
		p.list(System.out);
		// set tracing on for all connections
		server.trace(true);
		//test NetworkServerControl.setTraceDirectory
		server.setTraceDirectory(DERBY_SYSTEM_HOME);
		// get properties
		System.out.println("Properties with tracing on");
		p = server.getCurrentProperties();
		p.list(System.out);
		joinsignal();
	}
	catch (Exception e)
	{
		e.printStackTrace();
	}
}
 
Example 14
private Properties fetchRemoteProperties(String path, String[] profiles) throws Exception {
    Properties properties = new Properties();
    ZkPath[] zkPaths = new ZkPath[profiles.length+1];
    zkPaths[0] = ZkPath.create(path);
    for(int i=0; i<profiles.length; ++i) {
        zkPaths[i+1] = zkPaths[0].appendChild(profiles[i]);
    }
    fetchPropertiesRecursive(client, zkPaths, properties);
    properties.list(System.out);
    return properties;
}
 
Example 15
private void writeResult(double result, String file)
    throws FileNotFoundException {
  Properties timeProp = new Properties();
  timeProp.setProperty("YVALUE", ""+result);
  PrintStream os = new PrintStream(new File(reportDir, file));
  timeProp.list(os);
  os.close();
}
 
Example 16
Source Project: LoboBrowser   File: CobraURLConnection.java    License: MIT License 5 votes vote down vote up
private static String getSystemProperties() {
  final StringWriter swriter = new StringWriter();
  final PrintWriter writer = new PrintWriter(swriter);
  writer.println("<html>");
  writer.println("<head><title>Java Properties</title></head>");
  writer.println("<body>");
  writer.println("<pre>");
  final Properties properties = System.getProperties();
  properties.list(writer);
  writer.println("</pre>");
  writer.println("</body>");
  writer.println("</html>");
  writer.flush();
  return swriter.toString();
}
 
Example 17
Source Project: swift-k   File: GIPApplet.java    License: Apache License 2.0 5 votes vote down vote up
protected void doDebugTests() {
	try {    	
		System.err.println("doing some preleminary checks");
        
		Properties p = System.getProperties();
		p.list(System.out);
        
		InetAddress inetAdd = InetAddress.getLocalHost();
		System.out.println(inetAdd.getHostName());
		System.out.println(inetAdd.toString());
		System.out.println(inetAdd.getCanonicalHostName());
        
		System.out.println("trying to get property: org.globus.config.file");
		String file = System.getProperty("org.globus.config.file");
		System.out.println("got the property its values is: " + file);
        
		System.out.println("testing file acces");
		File fff = new File("_a_test_b_.txt");
		fff.createNewFile();
		System.out.println("successfully created _a_test_b_.txt");
        fff.delete();
        System.out.println("successfully deleted _a_test_b_.txt");
		System.out.println("preliminary checks ok");
	}
	catch( Exception eee ){
		eee.printStackTrace();
	}
}
 
Example 18
/**
 * @param args the command line arguments
 */
public static void main(String[] args)
{
	if( args.length != 1 )
	{
		System.err.println( "Usage: " + Main.class.getName() + " <props.file>" );
		System.exit( 1 );
	}
	else
	{
		try
		{
			System.out.println( "Loading props: " + args[ 0 ] );
			Properties p = new Properties();
			p.load( new FileInputStream( args[ 0 ] ) );
			p.list( System.out );
			new Main( p );
		}
		catch( Throwable th )
		{
			th.printStackTrace();
			th.printStackTrace( System.out );
			try
			{
				Thread.sleep( 1500 );
			}
			catch( InterruptedException ex )
			{
			}
			System.exit( 2 );				
		}
		System.exit( 0 );
	}
}
 
Example 19
public void processSpringComponents() {
		Enumeration<URL> springComponents = fetchResources("META-INF/spring.components");
		if (springComponents.hasMoreElements()) {
			log("Processing META-INF/spring.components files...");
			while (springComponents.hasMoreElements()) {
				URL springFactory = springComponents.nextElement();
				processSpringComponents(ts, springFactory);
			}
		} else {
//			System.out.println("No META-INF/spring.components found");
			System.out.println("Found no META-INF/spring.components -> generating one...");
			List<Entry<String, String>> components = scanClasspathForIndexedStereotypes();
			List<Entry<String,String>> filteredComponents = filterComponents(components);
			Properties p = new Properties();
			for (Entry<String,String> filteredComponent: filteredComponents) {
				String k = filteredComponent.getKey();
				System.out.println("- "+k);
				p.put(k, filteredComponent.getValue());
				reflectionHandler.addAccess(k,Flag.allDeclaredConstructors, Flag.allDeclaredMethods, Flag.allDeclaredClasses);
				ResourcesRegistry resourcesRegistry = ImageSingletons.lookup(ResourcesRegistry.class);
				resourcesRegistry.addResources(k.replace(".", "/")+".class");
				processComponent(k, new HashSet<>());
            }
            System.out.println("Computed spring.components is ");
			System.out.println("vvv");
			p.list(System.out);
			System.out.println("^^^");
			System.out.println(">>> "+p.toString());
			try {
				ByteArrayOutputStream baos = new ByteArrayOutputStream();
				p.store(baos,"");
				baos.close();
				byte[] bs = baos.toByteArray();
				ByteArrayInputStream bais = new ByteArrayInputStream(bs);
				Resources.registerResource("META-INF/spring.components", bais);
				System.out.println("BAOS: "+new String(bs));
			} catch (IOException e) {
				throw new IllegalStateException(e);
			}
		}
	}
 
Example 20
private static String getPropertyAsString(Properties prop) {
    StringWriter writer = new StringWriter();
    prop.list(new PrintWriter(writer));
    return writer.getBuffer().replace(0, "-- listing properties --\n".length(), "").toString();
}