private void overrideStorageEntryWithNewValue(String oldValue, String newValue)
     throws IOException {
   String newText = constructNewEntryText(oldValue, newValue);
   OutputStream storageOutputStream = storage.toPropertiesFile().getOutputStream();
   storageOutputStream.write(newText.getBytes("ISO-8859-1"));
   storageOutputStream.close();
 }
  private void deleteStorageEntry(String key) throws IOException {
    String currentText = storage.toPropertiesFile().asText();
    int index = currentText.indexOf(key);

    String before = currentText.substring(0, index);
    String after = currentText.substring(index + key.length() + 1);
    String newText = before.concat(after);

    OutputStream storageOutputStream = storage.toPropertiesFile().getOutputStream();
    storageOutputStream.write(newText.getBytes("ISO-8859-1"));
    storageOutputStream.close();
  }
Esempio n. 3
0
  /**
   * Generates an XML file that describes a filesystem structure.
   *
   * @param folder - where to place the file
   * @param composer a factory that assemblies resource strings
   */
  public static final File generateXMLFile(File folder, ResourceComposer composer)
      throws Exception {
    String name = MF_NAME + '-' + String.valueOf(composer.getFileBase());
    File dest = new File(folder, name.concat(".xml"));

    OutputStream os = new FileOutputStream(dest);
    Writer writer = new OutputStreamWriter(os);
    writer.write(generate(composer));
    writer.close();
    os.close();

    return dest;
  }
 private void overrideStorageEntryWithNewData(String newData) throws IOException {
   OutputStream storageOutputStream = storage.toPropertiesFile(true).getOutputStream();
   storageOutputStream.write(newData.getBytes("ISO-8859-1"));
   storageOutputStream.close();
 }