Here you can find the source of toProperties(File properties, File xml, String comment)
Parameter | Description |
---|---|
properties | the properties file. The xml file does not have to exist. |
xml | the xml file with the properties to convert. |
comment | the comment |
Parameter | Description |
---|---|
FileNotFoundException | the file not found exception |
IOException | Signals that an I/O exception has occurred. |
public static void toProperties(File properties, File xml, String comment) throws FileNotFoundException, IOException
//package com.java2s; /**//from ww w . ja v a 2 s . c o m * Copyright (C) 2007 Asterios Raptis * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.Properties; public class Main { /** * Converts the given xml file to the given properties file. * * @param properties * the properties file. The xml file does not have to exist. * @param xml * the xml file with the properties to convert. * @param comment * the comment * @throws FileNotFoundException * the file not found exception * @throws IOException * Signals that an I/O exception has occurred. */ public static void toProperties(File properties, File xml, String comment) throws FileNotFoundException, IOException { toProperties(new FileOutputStream(properties), new FileInputStream(xml), comment); } /** * Converts the given xml InputStream to the given properties OutputStream. * * @param properties * the properties file. The xml file does not have to exist. * @param xml * the xml file with the properties to convert. * @param comment * the comment * @throws FileNotFoundException * the file not found exception * @throws IOException * Signals that an I/O exception has occurred. */ public static void toProperties(OutputStream properties, InputStream xml, String comment) throws FileNotFoundException, IOException { Properties prop = new Properties(); prop.loadFromXML(xml); prop.store(properties, comment); } }