/** * Creates a process builder for the application, using the config, logging, and system * properties. */ ProcessBuilder createProcessBuilder() throws Exception { /* Create the application configuration file */ File configFile = File.createTempFile("SimpleApp", "config"); OutputStream configOut = new FileOutputStream(configFile); config.store(configOut, null); configOut.close(); /* Create the logging configuration file */ File loggingFile = File.createTempFile("SimpleApp", "logging"); OutputStream loggingOut = new FileOutputStream(loggingFile); logging.store(loggingOut, null); loggingOut.close(); /* Create the command line for running the Kernel */ List<String> command = new ArrayList<String>(); command.add(System.getProperty("java.home") + "/bin/java"); command.add("-cp"); command.add(System.getProperty("java.class.path")); command.add("-Djava.util.logging.config.file=" + loggingFile); command.add("-Djava.library.path=" + System.getProperty("java.library.path")); Enumeration<?> names = system.propertyNames(); while (names.hasMoreElements()) { Object name = names.nextElement(); command.add("-D" + name + "=" + system.get(name)); } command.add("com.sun.sgs.impl.kernel.Kernel"); command.add(configFile.toURI().toURL().getPath()); /* Return the process builder */ return new ProcessBuilder(command); }
private void writeOldPropertiesFiles(Properties props) throws IOException { OutputStream os1 = new FileOutputStream(pageOneOldFilename); props.store(os1, "test"); os1.close(); OutputStream os2 = new FileOutputStream(pageTwoOldFilename); props.store(os2, "test"); os2.close(); }
public static void save(File dataFolder) throws IOException { FileOutputStream playerClassesInput = new FileOutputStream(dataFolder + "/data_pc"); playerClasses.store(playerClassesInput, "player data - do not modify!"); playerClassesInput.close(); FileOutputStream playerManaInput = new FileOutputStream(dataFolder + "/data_pm"); playerMana.store(playerClassesInput, "player data - do not modify!"); playerManaInput.close(); }
/** * @return * @throws Exception */ public static Test suite() throws Exception { Logger.info("Starte Test-Suite"); TestSuite suite = new TestSuite("Test for de.jost_net.JVerein.Test"); // Altes Test-Verzeichnis loeschen, falls es existiert File dir = new File(WORK_DIR); if (dir.exists() && dir.isDirectory()) { Logger.info("Loesche altes Test-Verzeichnis " + dir); FileUtil.deleteRecursive(dir); } // Config erstellen, die auf die noetigen Plugins verweist OutputStream os = null; try { File configDir = new File(WORK_DIR, "cfg"); configDir.mkdirs(); Properties props = new Properties(); props.put("jameica.plugin.dir.0", "../hibiscus"); props.put("jameica.plugin.dir.1", "../jverein"); props.put("jameica.plugin.dir.2", "../jverein.test"); os = new BufferedOutputStream( new FileOutputStream(new File(configDir, Config.class.getName() + ".properties"))); props.store(os, ""); os.close(); props = new Properties(); props.put("window.maximized", "true"); os = new BufferedOutputStream( new FileOutputStream(new File(configDir, GUI.class.getName() + ".properties"))); props.store(os, ""); } finally { if (os != null) { os.close(); } } // Anwendung starten Logger.info("Starte Jameica"); String[] args = new String[] { "-f", WORK_DIR, // Arbeitsverzeichnis "-p", "test", // Master-Passwort // "-d" // Server-Mode - ohne GUI }; StartupParams params = new StartupParams(args); Application.newInstance(params); return suite; }
public void updatePropertiesMaster() throws IOException { properties = new Properties(); properties.setProperty( "hibernate.connection.driver_class", configParamSqlMaster.getConfigFieldDriver().getText()); properties.setProperty( "hibernate.connection.url", configParamSqlMaster.getConfigFieldURL().getText()); properties.setProperty( "hibernate.connection.username", configParamSqlMaster.getConfigFieldUser().getText()); properties.setProperty( "hibernate.connection.password", configParamSqlMaster.getConfigFieldPassword().getText()); properties.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLDialect"); properties.setProperty("hibernate.connection.pool_size", "10"); properties.setProperty("hibernate.show_sql", "true"); properties.setProperty("hibernate.format_sql", "true"); BufferedWriter out = null; try { out = new BufferedWriter( new OutputStreamWriter(new FileOutputStream("src/hibernateMaster.properties"))); } catch (FileNotFoundException ex) { JOptionPane.showMessageDialog( null, "updateValueMaster : Fichier de configuration MASTER introuvable:\n" + ex.getMessage()); } properties.store(out, ""); out.close(); }
void generatePropertiesFile(@NotNull Properties properties, File base, String propertiesFilename) throws IOException { FileWriter fileWriter = null; File gitPropsFile = new File(base, propertiesFilename); try { Files.createParentDirs(gitPropsFile); fileWriter = new FileWriter(gitPropsFile); if ("json".equalsIgnoreCase(format)) { log( "Writing json file to [", gitPropsFile.getAbsolutePath(), "] (for module ", project.getName() + (++counter), ")..."); ObjectMapper mapper = new ObjectMapper(); mapper.writeValue(fileWriter, properties); } else { log( "Writing properties file to [", gitPropsFile.getAbsolutePath(), "] (for module ", project.getName() + (++counter), ")..."); properties.store(fileWriter, "Generated by Git-Commit-Id-Plugin"); } } catch (IOException ex) { throw new RuntimeException("Cannot create custom git properties file: " + gitPropsFile, ex); } finally { Closeables.closeQuietly(fileWriter); } }
private synchronized void save() { myDir.mkdirs(); Properties props = new Properties(); props.setProperty(KIND_KEY, myKind.toString()); props.setProperty(ID_KEY, myRepositoryId); props.setProperty(PATH_OR_URL_KEY, myRepositoryPathOrUrl); props.setProperty(INDEX_VERSION_KEY, CURRENT_VERSION); if (myUpdateTimestamp != null) props.setProperty(TIMESTAMP_KEY, String.valueOf(myUpdateTimestamp)); if (myDataDirName != null) props.setProperty(DATA_DIR_NAME_KEY, myDataDirName); if (myFailureMessage != null) props.setProperty(FAILURE_MESSAGE_KEY, myFailureMessage); try { FileOutputStream s = new FileOutputStream(new File(myDir, INDEX_INFO_FILE)); try { props.store(s, null); } finally { s.close(); } } catch (IOException e) { MavenLog.LOG.warn(e); } }
public static void resetConfig() { try { menuProps.setProperty("selectedMenu", ""); menuProps.setProperty("loopMusic", "true"); menuProps.setProperty("muteMusic", "false"); menuProps.setProperty("lastMusicIndex", String.valueOf(jukebox.getIndexFromName("Strad"))); menuProps.setProperty("musicIndex", String.valueOf(jukebox.getIndexFromName("Strad"))); menuProps.setProperty("musicSet", "false"); menuProps.setProperty("hasPlayedMusic", "false"); menuProps.setProperty("hasStartedMusic", "false"); Minecraft.getMinecraft(); menuProps.store( new FileOutputStream(Minecraft.getMinecraftDir() + "/MenuAPI.properties"), null); Minecraft.getMinecraft(); FileInputStream in = new FileInputStream(Minecraft.getMinecraftDir() + "/MenuAPI.properties"); menuProps.load(in); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
public void loadGeneralWorldConfiguration() { Properties props = new Properties(); try { File configFile = new File(this.getDataFolder(), "MassiveWorldProperties.ini"); if (!configFile.exists()) { configFile.createNewFile(); props.load(new FileReader(configFile)); props.setProperty("worlds_enabled", "world,nether"); props.store(new FileWriter(configFile), "General Server Configurations"); } else { props.load(new FileReader(configFile)); } // I know, not very effective way of removing white space characters, but this allows for more // dynamic specifications String[] worlds = props.getProperty("worlds_enabled", "world,nether").replace(" ", "").split(","); for (String world : worlds) { if (this.getServer().getWorld(world) != null) { this.worlds.add(world); } } } catch (Exception ex) { log.log(Level.WARNING, "Unable to read MassiveProperties.ini"); } }
private void removeProperties(String propertiesFilePath, String... propertiesName) { if (propertiesName.length > 0) { Properties properties = CommandsUtils.readProperties(propertiesFilePath); if (properties != null && !properties.isEmpty()) { for (String propertieName : propertiesName) { if (properties.keySet().contains(propertieName)) { properties.remove(propertieName); } } FileOutputStream fos = null; try { fos = new FileOutputStream(propertiesFilePath); properties.store(fos, ""); } catch (FileNotFoundException e) { // nothing to do } catch (IOException e) { // nothing to do } finally { if (fos != null) { try { fos.close(); } catch (IOException e) { // nothing to do } } } } } }
private String getBucketName() throws FileNotFoundException { String path = "config" + File.separator + "bucket_name.properties"; FileInputStream fis; try { fis = new FileInputStream(path); Properties props = new Properties(); props.load(fis); fis.close(); String name = props.getProperty("bucketname"); if (name.length() == 0) { char[] randname = new char[10]; for (int i = 0; i < 10; i++) { char rand = (char) (Math.random() * 26 + 'a'); randname[i] = rand; } defaultBucketName = defaultBucketName.concat(new String(randname)); props.setProperty("bucketname", defaultBucketName); props.store(new FileOutputStream(path), "change"); } else { defaultBucketName = name; } } catch (IOException e) { e.printStackTrace(); } return null; }
@Override public void createNewPropertyFile() { Properties props = new Properties(); // The path of the properties file Path txtFile = Paths.get(Configurations.CONFIG_PROPERTIES_FILE_PATH); System.out.println("creating config file at " + txtFile.toString()); // Opening input and output streams for writing and reading files try (OutputStream txtOutStream = Files.newOutputStream(txtFile); ) { // Initialize the properties with 2 values props.setProperty("server.port", "3000"); props.setProperty("keepbackup", String.valueOf(true)); props.setProperty("path.source", Configurations.USER_DIRECTORY); props.setProperty("path.output", Configurations.USER_DIRECTORY + "output" + File.separator); props.setProperty("path.backup", Configurations.USER_DIRECTORY + "backup" + File.separator); props.setProperty("folder.name.assets", "assets"); props.setProperty("folder.name.content", "content"); props.setProperty("folder.name.templates", "templates"); props.setProperty("output.minify", String.valueOf(true)); // writing properties into properties file from Java props.store(txtOutStream, "Text Properties file generated from Shammy"); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
/** * 方法名: </br> 详述: </br>修改build文件配置文件 开发人员:谭明</br> 创建时间:Apr 1, 2014</br> * * @param project_path * @throws Exception */ public static void update_build_properties(String project_path) throws Exception { File file = new File(project_path + File.separator + "build.properties"); if (!file.exists()) { throw new Exception("项目build.properties文件不存在!"); } InputStream in; String key = "outdir"; String source_key = "app.source.path"; try { in = new BufferedInputStream(new FileInputStream(file)); Properties p = new Properties(); p.load(in); in.close(); System.out.println(p.get(key)); p.remove("a"); OutputStream fos = new FileOutputStream(file); p.setProperty(key, project_path + File.separator + "bin"); p.setProperty(source_key, project_path); p.store(fos, "Update '" + key + " and " + source_key + "' value"); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
private void btnGuardarActionPerformed( java.awt.event.ActionEvent evt) { // GEN-FIRST:event_btnGuardarActionPerformed try (OutputStream output = new FileOutputStream("db.properties")) { prop.setProperty("Servidor", txtServidor.getText()); prop.setProperty("Puerto", txtPuerto.getValue().toString()); prop.setProperty("BD", txtBasedeDatos.getText()); prop.setProperty("Usuario", txtUsuario.getText()); String contrasena = ""; for (char a : txtContrasena.getPassword()) { contrasena += a; } prop.setProperty("Clave", contrasena); prop.store(output, null); JOptionPane.showMessageDialog( this, "Configuración actualizada correctamente", "Correcto", JOptionPane.INFORMATION_MESSAGE); new Iniciar_Sesion().setVisible(true); dispose(); } catch (FileNotFoundException e) { error(); e.printStackTrace(); System.err.println(e.getClass().getName() + ": " + e.getMessage()); System.exit(0); } catch (IOException e) { error(); e.printStackTrace(); System.err.println(e.getClass().getName() + ": " + e.getMessage()); System.exit(0); } } // GEN-LAST:event_btnGuardarActionPerformed
/** * called every time a setting is changed saves settings file to * .minecraft/mods/$backendname/guiconfig.properties coming soon: set name of config file * * @param context The context to save. */ @SuppressWarnings("rawtypes") public void save(String context) { if (!settingsLoaded) { return; } try { File path = ModSettings.getAppDir( "/" + ModSettings.contextDatadirs.get(context) + "/" + backendname + "/"); ModSettings.dbgout( "saving context " + context + " (" + path.getAbsolutePath() + " [" + ModSettings.contextDatadirs.get(context) + "])"); if (!path.exists()) { path.mkdirs(); } File file = new File(path, "guiconfig.properties"); Properties p = new Properties(); for (int i = 0; i < Settings.size(); i++) { Setting z = Settings.get(i); p.put(z.backendName, z.toString(context)); } FileOutputStream out = new FileOutputStream(file); p.store(out, ""); } catch (Exception e) { e.printStackTrace(); } }
/** * Store item properties. * * @param iProps the i props * @throws StorageException the storage exception */ protected void storeItemProperties(ItemProperties iProps) throws StorageException { if (!iProps.isFile()) { throw new IllegalArgumentException("Only files can be stored!"); } logger.debug( "Storing metadata in [{}] in storage directory {}", iProps.getPath(), getMetadataBaseDir()); try { File target = new File(getMetadataBaseDir(), iProps.getPath()); target.getParentFile().mkdirs(); Properties metadata = new Properties(); metadata.putAll(iProps.getAllMetadata()); FileOutputStream os = new FileOutputStream(target); try { metadata.store(os, "Written by " + this.getClass()); os.flush(); } finally { os.close(); } target.setLastModified(iProps.getLastModified().getTime()); } catch (IOException ex) { throw new StorageException("IOException in FS storage " + getMetadataBaseDir(), ex); } }
public void getEnvAndSysPropertiesFromFile() throws IOException { // create a property file File propsFile = new File("tempPropFile"); propsFile.createNewFile(); Properties props = new Properties(); props.put(ENV_POPO_KEY, "buildname"); props.put(ENV_MOMO_KEY, "1"); props.store(new FileOutputStream(propsFile), ""); System.setProperty(BuildInfoConfigProperties.PROP_PROPS_FILE, propsFile.getAbsolutePath()); // Put system properties String kokoKey = "koko"; String gogoKey = "gogo"; System.setProperty(kokoKey, "parent"); System.setProperty(gogoKey, "2"); Properties buildInfoProperties = BuildInfoExtractorUtils.getEnvProperties(new Properties(), null); assertEquals( buildInfoProperties.getProperty(ENV_POPO_KEY), "buildname", "popo property does not match"); assertEquals( buildInfoProperties.getProperty(ENV_MOMO_KEY), "1", "momo number property does not match"); assertEquals( buildInfoProperties.getProperty("koko"), "parent", "koko parent name property does not match"); assertEquals( buildInfoProperties.getProperty("gogo"), "2", "gogo parent number property does not match"); propsFile.delete(); System.clearProperty(BuildInfoConfigProperties.PROP_PROPS_FILE); System.clearProperty(kokoKey); System.clearProperty(gogoKey); }
public static void main(String[] args) { FileInputStream fis = null; FileOutputStream fos = null; File file = new File("editor.def"); Properties props = new Properties(); try { fis = new FileInputStream(file); props.load(fis); fis.close(); } catch (IOException e) { System.out.println(e.getMessage()); e.printStackTrace(); } /* props.setProperty("file0", "ficheiro00000"); props.setProperty("file1", "ficheir011111111111"); props.setProperty("file2", "ficheir2 2 2 2"); */ props.list(System.out); // imprime o conteudo do objeto no console try { fos = new FileOutputStream(file); props.store(fos, "Configuração do editor"); fos.close(); } catch (IOException e) { System.out.println(e.getMessage()); e.printStackTrace(); } }
/** * 方法名: </br> 详述: </br>修改build文件配置文件 开发人员:谭明</br> 创建时间:Apr 1, 2014</br> * * @param project_path * @throws Exception */ public static void update_sysconfig_properties(String project_path) throws Exception { File file = new File(project_path + File.separator + "src" + File.separator + "sysConfig.properties"); if (!file.exists()) { throw new Exception("项目sysConfig.properties文件不存在!"); } InputStream in; try { in = new BufferedInputStream(new FileInputStream(file)); Properties p = new Properties(); p.load(in); in.close(); p.remove("a"); OutputStream fos = new FileOutputStream(file); p.setProperty("URL_SOCKET", ResourceBundle.getBundle("config").getString("socket_ip")); String url = ResourceBundle.getBundle("config").getString("push_url"); p.setProperty("URL_SERVER", url.replaceAll("\\\\", "")); p.setProperty("URL_SOCKETPORT", ResourceBundle.getBundle("config").getString("socket_port")); p.store(fos, "Update URL_SOCKET、URL_SERVER、URL_SOCKETPORT value"); fos.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } }
/** * Descripción de Método * * @param tryUserHome */ public static void saveProperties(boolean tryUserHome) { String fileName = getFileName(tryUserHome); FileOutputStream fos = null; try { File f = new File(fileName); fos = new FileOutputStream(f); s_prop.store(fos, "OpenXpertya"); fos.flush(); fos.close(); } catch (Exception e) { log.log(Level.SEVERE, "Cannot save Properties to " + fileName + " - " + e.toString()); return; } catch (Throwable t) { log.log(Level.SEVERE, "Cannot save Properties to " + fileName + " - " + t.toString()); return; } log.finer(fileName); } // save
@BeforeClass public static void setUp() throws Exception { KEY = MessageDigest.getInstance("SHA-256").digest(ALIAS.getBytes()); // Create a JKECS store containing a test secret key KeyStore store = KeyStore.getInstance("JCEKS"); store.load(null, PASSWORD.toCharArray()); store.setEntry( ALIAS, new KeyStore.SecretKeyEntry(new SecretKeySpec(KEY, "AES")), new KeyStore.PasswordProtection(PASSWORD.toCharArray())); // Create the test directory String dataDir = TEST_UTIL.getDataTestDir().toString(); new File(dataDir).mkdirs(); // Write the keystore file storeFile = new File(dataDir, "keystore.jks"); FileOutputStream os = new FileOutputStream(storeFile); try { store.store(os, PASSWORD.toCharArray()); } finally { os.close(); } // Write the password file Properties p = new Properties(); p.setProperty(ALIAS, PASSWORD); passwordFile = new File(dataDir, "keystore.pw"); os = new FileOutputStream(passwordFile); try { p.store(os, ""); } finally { os.close(); } }
/** * Writes the properties file. * * @param properties * @throws IOException */ private void write(Properties properties) throws IOException { // Write a temporary copy of the users file File realmFileCopy = new File(propertiesFile.getAbsolutePath() + ".tmp"); FileWriter writer = new FileWriter(realmFileCopy); properties.store( writer, " Gitblit realm file format:\n username=password,\\#permission,repository1,repository2...\n @teamname=!username1,!username2,!username3,repository1,repository2..."); writer.close(); // If the write is successful, delete the current file and rename // the temporary copy to the original filename. if (realmFileCopy.exists() && realmFileCopy.length() > 0) { if (propertiesFile.exists()) { if (!propertiesFile.delete()) { throw new IOException( MessageFormat.format("Failed to delete {0}!", propertiesFile.getAbsolutePath())); } } if (!realmFileCopy.renameTo(propertiesFile)) { throw new IOException( MessageFormat.format( "Failed to rename {0} to {1}!", realmFileCopy.getAbsolutePath(), propertiesFile.getAbsolutePath())); } } else { throw new IOException( MessageFormat.format("Failed to save {0}!", realmFileCopy.getAbsolutePath())); } }
public static void save(Properties properties, File file) throws IOException { Assert.notNull(properties, "存储的属性为空!"); OutputStream outputStream = new FileOutputStream(file); properties.store(outputStream, "saved on " + DateHelper.getStringDate()); outputStream.flush(); outputStream.close(); }
public static void main(String[] args) throws FileNotFoundException, IOException { Properties p = new Properties(); p.put("chouriço", "porco preto"); p.store( new PrintWriter("orgulhonacional"), "Eis uma lista de iguarias portuguesas com a respetiva \"fonte orgânica\""); }
public void loadBlockConfiguration(String dataWorld) { Properties props = new Properties(); try { // Create the file if it doesn't exist. File configFile = this.getFile(this.getDataWorldFile(dataWorld) + "/blockData/", "MassiveBlockEXP.ini"); if (!configFile.exists()) { configFile.createNewFile(); props.load(new FileReader(configFile)); props.setProperty("blocks_num", "96"); for (int i = 0; i < 96; i++) { props.setProperty(Material.getMaterial(i).name(), "0"); } props.store(new FileWriter(configFile), "Block Configuration for world " + dataWorld); } else { props.load(new FileReader(configFile)); } // Load the configuration. numBlock = Integer.parseInt(props.getProperty("blocks_num", "96")); for (int i = 0; i < numBlock; i++) { GeneralData.blockEXP.add(Integer.parseInt(props.getProperty(Integer.toString(i), "0"))); } } catch (Exception ex) { log.log(Level.WARNING, "Unable to load MassiveBlockEXP.ini"); } }
void saveResult(Result result) throws IOException { File file = new File(patchDir, result.getPatch().getId() + ".patch.result"); Properties props = new Properties(); FileOutputStream fos = new FileOutputStream(file); try { props.put(DATE, Long.toString(result.getDate())); props.put(UPDATES + "." + COUNT, Integer.toString(result.getUpdates().size())); int i = 0; for (BundleUpdate update : result.getUpdates()) { props.put( UPDATES + "." + Integer.toString(i) + "." + SYMBOLIC_NAME, update.getSymbolicName()); props.put(UPDATES + "." + Integer.toString(i) + "." + NEW_VERSION, update.getNewVersion()); props.put( UPDATES + "." + Integer.toString(i) + "." + NEW_LOCATION, update.getNewLocation()); props.put( UPDATES + "." + Integer.toString(i) + "." + OLD_VERSION, update.getPreviousVersion()); props.put( UPDATES + "." + Integer.toString(i) + "." + OLD_LOCATION, update.getPreviousLocation()); i++; } props.put(STARTUP, ((ResultImpl) result).getStartup()); String overrides = ((ResultImpl) result).getOverrides(); if (overrides != null) { props.put(OVERRIDES, overrides); } props.store(fos, "Installation results for patch " + result.getPatch().getId()); } finally { close(fos); } }
public void loadDatabaseConfiguration() { Properties props = new Properties(); try { File configFile = this.getFile(this.getDataFolder() + "/database/", "MassiveDatabase.ini"); if (!configFile.exists()) { configFile.createNewFile(); props.load(new FileReader(configFile)); props.setProperty("mysql_server_name", "localhost"); props.setProperty("mysql_port", ""); props.setProperty("mysql_database_name", "massive_database"); props.setProperty("mysql_user_name", "root"); props.setProperty("mysql_password", ""); props.setProperty("mysql_table_prefix", "mrpg"); props.store(new FileWriter(configFile), "Database Configurations"); } else { props.load(new FileReader(configFile)); } GeneralData.MySQLServerName = props.getProperty("mysql_server_name", "localhost"); GeneralData.MySQLPort = props.getProperty("mysql_port", ""); GeneralData.MySQLDBName = props.getProperty("mysql_database_name", "massive_database"); GeneralData.MySQLUserName = props.getProperty("mysql_user_name", "root"); GeneralData.MySQLPassword = props.getProperty("mysql_password", ""); GeneralData.MySQLPrefix = props.getProperty("mysql_table_prefix", "mrpg"); } catch (Exception ex) { log.log(Level.WARNING, "Unable to load MassiveDatabase.ini"); } }
private void saveConfigInfoIntoCache(String configType, String configInfo, IPath portalDir) { IPath versionsInfoPath = null; if (configType.equals(CONFIG_TYPE_VERSION)) { versionsInfoPath = LiferayServerCore.getDefault().getStateLocation().append("version.properties"); } else if (configType.equals(CONFIG_TYPE_SERVER)) { versionsInfoPath = LiferayServerCore.getDefault().getStateLocation().append("serverInfos.properties"); } if (versionsInfoPath != null) { File versionInfoFile = versionsInfoPath.toFile(); if (configInfo != null) { String portalDirKey = CoreUtil.createStringDigest(portalDir.toPortableString()); Properties properties = new Properties(); try (FileInputStream fileInput = new FileInputStream(versionInfoFile)) { properties.load(fileInput); } catch (Exception e) { } try (FileOutputStream fileOutput = new FileOutputStream(versionInfoFile)) { properties.put(portalDirKey, configInfo); properties.store(fileOutput, StringPool.EMPTY); } catch (Exception e) { LiferayServerCore.logError(e); } } } }
@Override public void creerCompte(Compte c) { // TODO File file = new File(fileName); FileOutputStream output = null; try { output = new FileOutputStream(file, true); Properties prop = new Properties(); String retour = ""; retour += "numero:" + c.getNumero() + "&intitulé:CC" + c.getIntitule() + "&solde:" + c.getSolde(); prop.setProperty(c.getNumero(), retour); // TODO découvert prop.store(output, null); } catch (IOException io) { io.printStackTrace(); } finally { if (output != null) { try { output.close(); } catch (IOException e) { e.printStackTrace(); } } } // TODO Auto-generated method stub }
public SaikuDatasource addDatasource(SaikuDatasource datasource) { try { String uri = repoURL.toURI().toString(); if (uri != null && datasource != null) { uri += datasource.getName().replace(" ", "_"); File dsFile = new File(new URI(uri)); if (dsFile.exists()) { dsFile.delete(); } else { dsFile.createNewFile(); } FileWriter fw = new FileWriter(dsFile); Properties props = datasource.getProperties(); props.store(fw, null); fw.close(); datasources.put(datasource.getName(), datasource); return datasource; } else { throw new SaikuServiceException( "Cannot save datasource because uri or datasource is null uri(" + (uri == null) + ")"); } } catch (Exception e) { throw new SaikuServiceException("Error saving datasource", e); } }