Package VASSAL.tools

Class ArchiveWriter

All Implemented Interfaces:
Closeable, AutoCloseable

public class ArchiveWriter
extends DataArchive
An ArchiveWriter is a writeable DataArchive. New files may be added with the addFile(java.lang.String, java.lang.String) and addImage(java.lang.String, java.lang.String) methods.
  • Constructor Details

    • ArchiveWriter

      public ArchiveWriter​(String zipName, String ext)
    • ArchiveWriter

      public ArchiveWriter​(String zipName)
      Create a new writeable archive.
      Parameters:
      zipName - the name of the archive. If null, the user will be prompted for a filename when saving. If not null, new entries will be added to the named archive. If the file exists and is not a zip archive, it will be overwritten.
    • ArchiveWriter

      public ArchiveWriter​(FileArchive archive)
    • ArchiveWriter

      @Deprecated(since="2020-08-06", forRemoval=true) public ArchiveWriter​(ZipFile archive)
      Deprecated, for removal: This API element is subject to removal in a future version.
  • Method Details

    • addImage

      public void addImage​(String path, String name)
      Add an image file to the archive. The file will be copied into an "images" directory in the archive. Storing another image with the same name will overwrite the previous image.
      Parameters:
      path - the full path of the image file on the user's filesystem
      name - the name under which to store the image in the archive
    • addImage

      public void addImage​(String name, byte[] contents)
    • addSound

      public void addSound​(String path, String fileName)
    • isImageAdded

      @Deprecated(since="2020-08-06", forRemoval=true) public boolean isImageAdded​(String name)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • removeImage

      public void removeImage​(String name)
    • addFile

      public void addFile​(String path, String fileName)
      Copy a file from the user's filesystem to the archive.
      Parameters:
      path - the full path of the file on the user's filesystem
      fileName - the name under which to store the file in the archive
    • addFile

      public void addFile​(String fileName, InputStream in)
      Copy an InputStream into the archive
      Parameters:
      fileName - the name under which to store the contents of the stream
      in - the stream to copy
    • addFile

      public void addFile​(String fileName, byte[] content)
    • save

      public void save() throws IOException
      Throws:
      IOException
    • save

      public void save​(boolean notifyModuleManager) throws IOException
      Throws:
      IOException
    • saveAs

      public void saveAs() throws IOException
      Throws:
      IOException
    • write

      protected void write​(FileArchive fa, boolean notifyModuleManager) throws IOException
      Throws:
      IOException
    • saveAs

      public void saveAs​(boolean notifyModuleManager) throws IOException
      Throws:
      IOException
    • write

      @Deprecated(since="2020-08-06", forRemoval=true) public void write() throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      If the ArchiveWriter was initialized with non-null file name, then write the contents of the archive to the named archive. If it was initialized with a null name, prompt the user to select a new file into which to write archive.
      Throws:
      IOException
    • write

      @Deprecated(since="2020-08-06", forRemoval=true) public void write​(boolean notifyModuleManager) throws IOException
      Deprecated, for removal: This API element is subject to removal in a future version.
      Throws:
      IOException