Java Utililty Methods Properties Save

List of utility methods to do Properties Save

Description

The list of methods to do Properties Save are organized into topic(s).

Method

voidsave()
Internal method to persist all the settings to the file
if (properties != null) {
    try {
        properties.store(new FileWriter(SETTINGS_FILEPATH), "");
    } catch (IOException e) {
        e.printStackTrace();
voidsave()
save
try {
    FileOutputStream fos = new FileOutputStream(cfgPath);
    p.setProperty("bbb", "333444");
    p.store(fos, "");
    fos.flush();
    fos.close();
    System.out.println("store properties success");
} catch (Exception e) {
...
voidsave(File file, Properties properties)
Saves the given Properties to the given File .
if (!file.exists()) {
    if (!file.getParentFile().exists()) {
        boolean mkdirs = file.getParentFile().mkdirs();
        if (!mkdirs) {
            throw new IOException(String.format("Failed to create parent directories of file %s",
                    file.getAbsolutePath()));
    boolean createFile = file.createNewFile();
    if (!createFile) {
        throw new IOException(String.format("Failed to create file %s", file.getAbsolutePath()));
FileWriter f_writer = new FileWriter(file);
try {
    properties.store(f_writer, null);
} catch (IOException ex) {
    f_writer.close();
    throw ex;
f_writer.close();
voidsave(Properties properties, File propertiesFile)
Saves properties to a file.
OutputStream out = null;
try {
    checkNotNull(propertiesFile).getParentFile().mkdirs();
    out = new BufferedOutputStream(new FileOutputStream(propertiesFile));
    if (propertiesFile.getName().endsWith(".xml")) {
        properties.storeToXML(out, null);
    } else {
        properties.store(out, null);
...
voidsave(Properties props, File file, String comment)
save
try (OutputStream stream = new FileOutputStream(file)) {
    props.store(stream, comment);
    stream.close();
voidsave(String fileName, CharSequence string)
Saves the specified character sequence.
File file;
try {
    Properties props = new Properties();
    props.loadFromXML(new FileInputStream(propertyFile));
    file = new File(
            props.getProperty("currentDirectory") + System.getProperty("file.separator") + fileName);
} catch (Exception e) {
    file = new File(fileName);
...
voidsaveBuildConfiguration(IFile ifile)
save Build Configuration
File file = ifile.getLocation().toFile();
IProject project = ifile.getProject();
try {
    IJavaProject jp = JavaCore.create(project);
    IClasspathEntry[] entries = jp.getRawClasspath();
    List srcIncludes = new ArrayList();
    List srcExcludes = new ArrayList();
    List srcInclusionpatterns = new ArrayList();
...
voidsaveConfig()
Save the current config to disk.
if (props == null)
    return;
props.store(new FileWriter(cfg), null);
voidsaveConfig(File settingsFile, Properties properties)
save Config
FileOutputStream settingsOut = new FileOutputStream(settingsFile);
properties.store(settingsOut, "Ticket check settings");
settingsOut.close();
voidsaveDefaultScriptDirectory(String path)
save Default Script Directory
config.setProperty(DEFAULT_SCRIPT_DIR, path);
store();