Class PstStoreWriter

java.lang.Object
com.independentsoft.pst.PstStoreWriter

public class PstStoreWriter extends Object
Writes a new Unicode PST file from a tree of PstFolderWriter/PstMessageWriter objects, or edits an existing PST in place (open it, add folders/items via getRoot(), then save(String)).
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initializes a new instance of the PstStoreWriter class.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    addFolder(long parentNid, Folder folder)
    Adds a folder under the folder with the given node id, returning its node id.
    long
    addFolder(Folder folder)
    Adds a folder under the top of the personal-folders subtree, returning its node id.
    long
    Adds a folder under the top of the personal-folders subtree, returning its node id.
    long
    addItem(long folderNid, Item item)
    Adds an item to the folder with the given node id, returning the new item's node id.
    addItems(long folderNid, List<Item> items)
    Adds many items to a folder in a single pass (one contents-table rebuild and one count update for all).
    void
    Releases the working file used while editing.
    getFolder(long nid)
    Gets a writer-attached navigable Folder for the given nid in the edited store (null if not found).
    Gets the editable root folder ("Top of Personal Folders") of a store opened with open(String).
    Gets the root user folder ("Top of Personal Folders").
    boolean
    Gets whether to include the default search-folder infrastructure.
    void
    open(InputStream stream)
    Opens an existing PST from a stream for editing.
    void
    open(String filePath)
    Opens an existing PST file for editing.
    void
    Writes the PST file to the specified stream.
    void
    save(String filePath)
    Writes the PST file to the specified path.
    void
    setIncludeSearchFolder(boolean includeSearchFolder)
    Sets whether to include the default search-folder infrastructure.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • PstStoreWriter

      public PstStoreWriter()
      Initializes a new instance of the PstStoreWriter class.
  • Method Details

    • isIncludeSearchFolder

      public boolean isIncludeSearchFolder()
      Gets whether to include the default search-folder infrastructure.
      Returns:
      whether the search-folder infrastructure is included.
    • setIncludeSearchFolder

      public void setIncludeSearchFolder(boolean includeSearchFolder)
      Sets whether to include the default search-folder infrastructure.
      Parameters:
      includeSearchFolder - whether the search-folder infrastructure is included.
    • getTopOfPersonalFolders

      public PstFolderWriter getTopOfPersonalFolders()
      Gets the root user folder ("Top of Personal Folders"). Folders added here appear under the store in Outlook.
      Returns:
      the top-of-personal-folders writer.
    • open

      public void open(String filePath) throws IOException
      Opens an existing PST file for editing. Subsequent changes are written by save(String).
      Parameters:
      filePath - the PST file to open.
      Throws:
      IOException - if an I/O error occurs.
    • open

      public void open(InputStream stream) throws IOException
      Opens an existing PST from a stream for editing.
      Parameters:
      stream - the source stream.
      Throws:
      IOException - if an I/O error occurs.
    • addFolder

      public long addFolder(String name) throws IOException
      Adds a folder under the top of the personal-folders subtree, returning its node id.
      Parameters:
      name - the display name of the new folder.
      Returns:
      the new folder's NID.
      Throws:
      IOException - if an I/O error occurs.
    • addFolder

      public long addFolder(Folder folder) throws IOException
      Adds a folder under the top of the personal-folders subtree, returning its node id.
      Parameters:
      folder - the folder to add.
      Returns:
      the new folder's NID.
      Throws:
      IOException - if an I/O error occurs.
    • addFolder

      public long addFolder(long parentNid, Folder folder) throws IOException
      Adds a folder under the folder with the given node id, returning its node id.
      Parameters:
      parentNid - the parent folder's node id.
      folder - the folder to add.
      Returns:
      the new folder's NID.
      Throws:
      IOException - if an I/O error occurs.
    • getRoot

      public Folder getRoot() throws IOException
      Gets the editable root folder ("Top of Personal Folders") of a store opened with open(String).
      Returns:
      the editable root folder.
      Throws:
      IOException - if an I/O error occurs.
    • getFolder

      public Folder getFolder(long nid) throws IOException
      Gets a writer-attached navigable Folder for the given nid in the edited store (null if not found).
      Parameters:
      nid - the folder node id.
      Returns:
      the folder, or null.
      Throws:
      IOException - if an I/O error occurs.
    • addItem

      public long addItem(long folderNid, Item item) throws IOException
      Adds an item to the folder with the given node id, returning the new item's node id.
      Parameters:
      folderNid - the target folder's node id.
      item - the item to add.
      Returns:
      the new item's NID.
      Throws:
      IOException - if an I/O error occurs.
    • addItems

      public List<Long> addItems(long folderNid, List<Item> items) throws IOException
      Adds many items to a folder in a single pass (one contents-table rebuild and one count update for all).
      Parameters:
      folderNid - the target folder's node id.
      items - the items to add.
      Returns:
      the new item NIDs.
      Throws:
      IOException - if an I/O error occurs.
    • save

      public void save(String filePath) throws IOException
      Writes the PST file to the specified path.
      Parameters:
      filePath - the destination file path.
      Throws:
      IOException - if an I/O error occurs.
    • save

      public void save(OutputStream stream) throws IOException
      Writes the PST file to the specified stream.
      Parameters:
      stream - the destination stream.
      Throws:
      IOException - if an I/O error occurs.
    • close

      public void close() throws IOException
      Releases the working file used while editing. Call after save(String) when done editing.
      Throws:
      IOException - if an I/O error occurs.