Deserialize, then output the given configuration. If two parameters are
given, the first one is the filename and the second is the properties
file to apply before re-serializing.
769905
public static void main(String[] args) throws Exception {
        if (args.length < 1 || args.length > 2) {
            throw new IOException("One or two arguments expected.");
        }
        ServerConfiguration config =
                new ServerConfigurationParser(new FileInputStream(new File(args[0])))
                        .parse();
        if (args.length == 2) {
            Properties props = new Properties();
            props.load(new FileInputStream(new File(args[1])));
            config.applyProperties(props);
        }
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        config.serialize(out);
        String content = new String(out.toByteArray(), "UTF-8");
        System.out.println(content);
    }
921110
private void writePropertyData() {
		try (PrintStream out = new PrintStream(openResultFileOuputStream(
				resultDirectory, "properties.json"))) {
			out.println("{");

			int count = 0;
			for (Entry<Integer, PropertyRecord> propertyEntry : this.propertyRecords
					.entrySet()) {
				if (count > 0) {
					out.println(",");
				}
				out.print("\"" + propertyEntry.getKey() + "\":");
				mapper.writeValue(out, propertyEntry.getValue());
				count++;
			}
			out.println("\n}");

			System.out.println(" Serialized information for " + count
					+ " properties.");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
710627
public synchronized void storeConfiguration() throws IOException
    {
        OutputStream out = new FileOutputStream(configFilePath);
        configuration.store(out, configFilePath);
    }
844092
def write(filename, jobject):
    
    if isinstance(jobject, JavaObject):
        jobject = jobject.jobject
    javabridge.static_call(
        "Lweka/core/SerializationHelper;", "write",
        "(Ljava/lang/String;Ljava/lang/Object;)V",
        filename, jobject)
331538
@SuppressWarnings("unchecked")
	public static Map<String,Object> deserializeMapFromFile(String filesystem, String filename) {
		Map<String,Object> map;
		if (filesystem.equals(HDFS)) {
			map = (Map<String,Object>) HDFSUtils.deserializeObjectFromFile(filename);
		}
		else {
			map = (Map<String,Object>) LocalFileSystemUtils.deserializeObjectFromLocalFile(filename);
		}
		return map;
	}
1097472
def deserialize(stream_or_string, **options):
    '''
    
    '''

    if six.PY3:
        cp = configparser.ConfigParser(**options)
    else:
        cp = configparser.SafeConfigParser(**options)

    try:
        if not isinstance(stream_or_string, (bytes, six.string_types)):
            if six.PY3:
                cp.read_file(stream_or_string)
            else:
                cp.readfp(stream_or_string)
        else:
            if six.PY3:
                cp.read_file(six.moves.StringIO(stream_or_string))
            else:
                # python2's ConfigParser cannot parse a config from a string
                cp.readfp(six.moves.StringIO(stream_or_string))
        data = {}
        for section_name in cp.sections():
            section = {}
            for k, v in cp.items(section_name):
                section[k] = v
            data[section_name] = section
        return data
    except Exception as error:
        raise DeserializationError(error)
95447
public static void writePropertiesFile( Properties properties, File file ) throws IOException {

		OutputStream out = null;
		try {
			out = new FileOutputStream( file );
			properties.store( out, "" );

		} finally {
			closeQuietly( out );
		}
	}
296779
@Benchmark
	@BenchmarkMode(Mode.AverageTime)
	public void byteArrayFileOutputStream(final Configuration configuration) throws IOException {
		byte[] buffer = new byte[BUFFER_CAPACITY];
		int position = 0;

		try (OutputStream stream = new FileOutputStream(configuration.file)) {
			for (long i = 0; i < LINES; ++i) {
				if (BUFFER_CAPACITY - position < DATA.length) {
					stream.write(buffer, 0, position);
					position = 0;
				}

				if (BUFFER_CAPACITY < DATA.length) {
					stream.write(DATA);
				} else {
					System.arraycopy(DATA, 0, buffer, position, DATA.length);
					position += DATA.length;
				}
			}

			if (position > 0) {
				stream.write(buffer, 0, position);
			}
		}
	}
431311
@Override
	public void configure(Configuration parameters) {
		// get the output file path, if it was not yet set
		if (this.outputFilePath == null) {
			// get the file parameter
			String filePath = parameters.getString(FILE_PARAMETER_KEY, null);
			if (filePath == null) {
				throw new IllegalArgumentException("The output path has been specified neither via constructor/setters" +
						", nor via the Configuration.");
			}
			
			try {
				this.outputFilePath = new Path(filePath);
			}
			catch (RuntimeException rex) {
				throw new RuntimeException("Could not create a valid URI from the given file path name: " + rex.getMessage()); 
			}
		}
		
		// check if have not been set and use the defaults in that case
		if (this.writeMode == null) {
			this.writeMode = DEFAULT_WRITE_MODE;
		}
		
		if (this.outputDirectoryMode == null) {
			this.outputDirectoryMode = DEFAULT_OUTPUT_DIRECTORY_MODE;
		}
	}
1012022
def _serialize(self, convert_to_key_and_value, ignore_missing=False):
        

        serialized = {}
        properties = self._get_property_names(self)

        def get_property_detail(name):
            p = [p for p in self._property_details if p.name == name]
            return None if len(p) == 0 else p[0]

        for p in properties:
            pd = get_property_detail(p)
            value = self._property_to_field(p, pd)
            field_name = p if not pd else pd.to_field_name()

            if value is None or (ignore_missing and not value) or (pd and pd.unsent):
                continue
            else:
                key, value = convert_to_key_and_value(field_name, value, pd)
                if key:
                    serialized[key] = value

        return serialized
93635
def decompile_file(filename, outstream=None, showasm=None, showast=False,
                   showgrammar=False, mapstream=None, do_fragments=False):
    

    filename = check_object_path(filename)
    code_objects = {}
    (version, timestamp, magic_int, co, is_pypy,
        source_size) = load_module(filename, code_objects)

    if isinstance(co, list):
        deparsed = []
        for con in co:
            deparsed.append(
                decompile(version, con, outstream, showasm, showast,
                          timestamp, showgrammar, code_objects=code_objects,
                          is_pypy=is_pypy, magic_int=magic_int),
                          mapstream=mapstream)
    else:
        deparsed = [decompile(version, co, outstream, showasm, showast,
                              timestamp, showgrammar,
                              code_objects=code_objects, source_size=source_size,
                              is_pypy=is_pypy, magic_int=magic_int,
                              mapstream=mapstream, do_fragments=do_fragments)]
    co = None
    return deparsed
751177
def build_configuration_parameters(app):
    """"""
    env = Environment(loader=FileSystemLoader("{0}/_data_templates".format(BASEPATH)))
    template_file = env.get_template("configuration-parameters.j2")
    data = {}
    data["schema"] = Config.schema()
    rendered_template = template_file.render(**data)
    output_dir = "{0}/configuration/generated".format(BASEPATH)
    with open("{}/parameters.rst".format(output_dir), "w") as f:
        f.write(rendered_template)
832208
@Override
    protected void initializeImpl(Map<String,String> configuration)
    {
        //create configuration holder
        ConfigurationHolder configurationHolder=new ConfigurationHolderImpl(configuration);

        this.fileContentParameter=configurationHolder.getConfigurationValue(HTTPRequestParserConfigurationConstants.FILE_CONTENT_PARAMETER_NAME_PROPERTY_KEY);
        if(this.fileContentParameter==null)
        {
            this.fileContentParameter="file";
        }
        this.fileNameParameter=configurationHolder.getConfigurationValue(HTTPRequestParserConfigurationConstants.FILE_NAME_PARAMETER_NAME_PROPERTY_KEY);
        if(this.fileNameParameter==null)
        {
            this.fileNameParameter="filename";
        }
        this.priorityParameter=configurationHolder.getConfigurationValue(HTTPRequestParserConfigurationConstants.PRIORITY_PARAMETER_NAME_PROPERTY_KEY);
        if(this.priorityParameter==null)
        {
            this.priorityParameter="priority";
        }
        this.targetAddressParameter=configurationHolder.getConfigurationValue(HTTPRequestParserConfigurationConstants.TARGET_ADDRESS_PARAMETER_NAME_PROPERTY_KEY);
        if(this.targetAddressParameter==null)
        {
            this.targetAddressParameter="targetaddress";
        }
        this.targetNameParameter=configurationHolder.getConfigurationValue(HTTPRequestParserConfigurationConstants.TARGET_NAME_PARAMETER_NAME_PROPERTY_KEY);
        if(this.targetNameParameter==null)
        {
            this.targetNameParameter="targetname";
        }
        this.senderNameParameter=configurationHolder.getConfigurationValue(HTTPRequestParserConfigurationConstants.SENDER_NAME_PARAMETER_NAME_PROPERTY_KEY);
        if(this.senderNameParameter==null)
        {
            this.senderNameParameter="sendername";
        }
        this.senderFaxNumberParameter=configurationHolder.getConfigurationValue(HTTPRequestParserConfigurationConstants.SENDER_FAX_NUMBER_PARAMETER_NAME_PROPERTY_KEY);
        if(this.senderFaxNumberParameter==null)
        {
            this.senderFaxNumberParameter="senderfaxnumber";
        }
        this.senderEMailParameter=configurationHolder.getConfigurationValue(HTTPRequestParserConfigurationConstants.SENDER_EMAIL_PARAMETER_NAME_PROPERTY_KEY);
        if(this.senderEMailParameter==null)
        {
            this.senderEMailParameter="senderemail";
        }
    }
128670
private static Properties initializeConfigurationProperties() {
		Properties properties = new Properties();

		InputStream in = GeoPackageProperties.class.getResourceAsStream("/"
				+ PropertyConstants.PROPERTIES_FILE);
		if (in != null) {
			try {
				properties.load(in);
			} catch (Exception e) {
				log.log(Level.SEVERE, "Failed to load properties file: "
						+ PropertyConstants.PROPERTIES_FILE, e);
			} finally {
				try {
					in.close();
				} catch (IOException e) {
					log.log(Level.WARNING, "Failed to close properties file: "
							+ PropertyConstants.PROPERTIES_FILE, e);
				}
			}
		} else {
			log.log(Level.SEVERE, "Failed to load properties, file not found: "
					+ PropertyConstants.PROPERTIES_FILE);
		}

		return properties;
	}
339455
private static Properties load(String configFilePath)
	{
		Properties props = new Properties();
		BufferedInputStream fis = null;
		try {
			File configFile = new File(configFilePath);
	        fis = new BufferedInputStream(new FileInputStream(configFile));
	        props.load(fis);
        }
        catch(IOException e){
        	System.err.println("Could not load configuration file "+configFilePath);
        }
        finally{
			if(fis!=null){
			    try {
					fis.close();
				}
				catch (IOException e) {
		        	System.err.println("Error closing file stream of configuration file "+configFilePath);
				}
			}
        }
        return props;
	}
1144493
static void generateProjectPropertiesFile(
            final String name,
            final File destfile,
            final boolean overwrite,
            final Properties properties,
            boolean addDefaultProps
    )
    {

        generateProjectPropertiesFile(name, destfile, overwrite, properties, false, null, addDefaultProps);
    }
1288703
private void writeObject(ObjectOutputStream out) throws IOException {
		out.writeInt(this.fieldNames.length);
		for (String fieldName : this.fieldNames) {
			out.writeUTF(fieldName);
		}
		this.configuration.write(out);
	}