List of usage examples for org.apache.commons.configuration PropertiesConfiguration save
public void save() throws ConfigurationException
From source file:org.xwiki.filter.confluence.xml.internal.ConfluenceXMLPackage.java
private void saveUserProperties(PropertiesConfiguration properties, int userId) throws IOException, ConfigurationException { PropertiesConfiguration fileProperties = getUserProperties(userId); fileProperties.copy(properties);/*from w w w . ja va 2s.c om*/ fileProperties.save(); }
From source file:org.xwiki.filter.confluence.xml.internal.ConfluenceXMLPackage.java
private void saveGroupProperties(PropertiesConfiguration properties, int groupId) throws IOException, ConfigurationException { PropertiesConfiguration fileProperties = getGroupProperties(groupId); fileProperties.copy(properties);/* ww w . jav a 2 s . c o m*/ fileProperties.save(); }
From source file:org.xwiki.filter.confluence.xml.internal.ConfluenceXMLPackage.java
private void saveAttachmentProperties(PropertiesConfiguration properties, int pageId, int attachmentId) throws IOException, ConfigurationException { PropertiesConfiguration fileProperties = getAttachmentProperties(pageId, attachmentId); fileProperties.copy(properties);/* w ww . j a va 2s. c om*/ fileProperties.save(); }
From source file:org.xwiki.filter.confluence.xml.internal.ConfluenceXMLPackage.java
private void saveSpacePermissionsProperties(PropertiesConfiguration properties, int spaceId, int permissionId) throws IOException, ConfigurationException { PropertiesConfiguration fileProperties = getSpacePermissionProperties(spaceId, permissionId); fileProperties.copy(properties);/*from w ww.java 2s . co m*/ fileProperties.save(); }
From source file:org.xwiki.filter.confluence.xml.internal.ConfluenceXMLPackage.java
private void saveSpaceProperties(PropertiesConfiguration properties, int spaceId) throws IOException, ConfigurationException { PropertiesConfiguration fileProperties = getSpaceProperties(spaceId); fileProperties.copy(properties);//from ww w. j a v a2 s. com fileProperties.save(); }
From source file:pl.otros.vfs.browser.demo.TestBrowser.java
public static void main(final String[] args) throws InterruptedException, InvocationTargetException, SecurityException, IOException { if (args.length > 1) throw new IllegalArgumentException( "SYNTAX: java... " + TestBrowser.class.getName() + " [initialPath]"); SwingUtilities.invokeAndWait(new Runnable() { @Override// www .ja v a2s. c om public void run() { tryLoadSubstanceLookAndFeel(); final JFrame f = new JFrame("OtrosVfsBrowser demo"); Container contentPane = f.getContentPane(); contentPane.setLayout(new BorderLayout()); DataConfiguration dc = null; final PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(); File favoritesFile = new File("favorites.properties"); propertiesConfiguration.setFile(favoritesFile); if (favoritesFile.exists()) { try { propertiesConfiguration.load(); } catch (ConfigurationException e) { e.printStackTrace(); } } dc = new DataConfiguration(propertiesConfiguration); propertiesConfiguration.setAutoSave(true); final VfsBrowser comp = new VfsBrowser(dc, (args.length > 0) ? args[0] : null); comp.setSelectionMode(SelectionMode.FILES_ONLY); comp.setMultiSelectionEnabled(true); comp.setApproveAction(new AbstractAction(Messages.getMessage("demo.showContentButton")) { @Override public void actionPerformed(ActionEvent e) { FileObject[] selectedFiles = comp.getSelectedFiles(); System.out.println("Selected files count=" + selectedFiles.length); for (FileObject selectedFile : selectedFiles) { try { FileSize fileSize = new FileSize(selectedFile.getContent().getSize()); System.out.println(selectedFile.getName().getURI() + ": " + fileSize.toString()); byte[] bytes = readBytes(selectedFile.getContent().getInputStream(), 150 * 1024l); JScrollPane sp = new JScrollPane(new JTextArea(new String(bytes))); JDialog d = new JDialog(f); d.setTitle("Content of file: " + selectedFile.getName().getFriendlyURI()); d.getContentPane().add(sp); d.setSize(600, 400); d.setVisible(true); } catch (Exception e1) { LOGGER.error("Failed to read file", e1); JOptionPane.showMessageDialog(f, (e1.getMessage() == null) ? e1.toString() : e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } } } }); comp.setCancelAction(new AbstractAction(Messages.getMessage("general.cancelButtonText")) { @Override public void actionPerformed(ActionEvent e) { f.dispose(); try { propertiesConfiguration.save(); } catch (ConfigurationException e1) { e1.printStackTrace(); } System.exit(0); } }); contentPane.add(comp); f.pack(); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }); }
From source file:tagtime.settings.Settings.java
/** * Creates a new settings manager for the given user. */// www .j a va 2 s.c o m private Settings(String userName) { //setup this.username = userName; //settingValues = new EnumMap<SettingType, Object>(SettingType.class); String fileLocation = Main.getDataDirectory().getPath() + "/" + userName + ".properties"; //load the file PropertiesConfiguration tempProperties; try { tempProperties = new PropertiesConfiguration(fileLocation); } catch (ConfigurationException e) { //file not found tempProperties = new PropertiesConfiguration(); tempProperties.setPath(fileLocation); try { tempProperties.save(); } catch (ConfigurationException e1) { e1.printStackTrace(); } } properties = tempProperties; /*if(settingsFile.exists()) { //read the save file and load the settings BufferedReader in = new BufferedReader(new FileReader(settingsFile)); readInSettings(in); //TagTime doesn't bother reading the file from here on; if the //user changes it, those changes will be overwritten in.close(); } else { applyDefaultSettings(); flush(); }*/ }
From source file:test.db_memory.QualitativeTest.java
private static void setCacheForDb(TestDescription test) { String confFileName = String.format("%s/conf.properties", test.getInputDb()); try {/* ww w . j av a 2s . c o m*/ PropertiesConfiguration config = new PropertiesConfiguration(new File(confFileName)); config.setProperty("storage.batch-loading", "false"); config.setProperty("cache.db-cache", "true"); config.setProperty("cache.db-cache-size", "250000000"); config.setProperty("cache.db-cache-time", "0"); config.setProperty("query.batch", "true"); config.setProperty("query.fast-property", "true"); config.setProperty("storage.transactions", "false"); config.setProperty("storage.read-only", "false"); config.save(); } catch (ConfigurationException ex) { java.util.logging.Logger.getLogger(QualitativeTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:umich.ms.batmass.filesupport.core.types.descriptor.FileDescriptor.java
/** * Saves a FileDescriptor to a properties based file. * @param file File to save the descriptor to * @param desc Descriptor to be saved//from w w w . j a va2 s . com * @throws org.apache.commons.configuration.ConfigurationException */ public static void writeToFile(File file, FileDescriptor desc) throws ConfigurationException { PropertiesConfiguration conf = new PropertiesConfiguration(file); conf.setProperty(PROP_UID, desc.getUID()); conf.setProperty(PROP_PATH, desc.getPath().toString()); conf.setProperty(PROP_SIZE, desc.getSize()); conf.setProperty(PROP_FILE_CATEGORY, desc.getFileCategory()); conf.setProperty(PROP_FILE_TYPE, desc.getFileType()); List<Path> children = desc.getChildren(); String[] paths = new String[children.size()]; for (int i = 0; i < paths.length; i++) { paths[i] = children.get(i).toString(); } conf.setProperty(PROP_CHILDREN, paths); conf.save(); }
From source file:umich.ms.batmass.projects.core.type.BMProjectFactory.java
public void createProjectDirStructure(Path path, String name) throws IOException, ConfigurationException { Path projDirPath = Paths.get(path.toAbsolutePath().toString(), getProjectDir()); Files.createDirectories(projDirPath); Path projPropFile = Paths.get(projDirPath.toString(), getProjectPropfile()); Files.createFile(projPropFile); PropertiesConfiguration config = new PropertiesConfiguration(projPropFile.toFile()); config.addProperty(BMProject.PROP_NAME, name); config.save(); }