# Class PstFile

java.lang.Object
com.independentsoft.pst.PstFile

public class PstFile extends Object
The Class PstFile.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PstFile()`
  Instantiates a new pst file.
  `PstFile(File file)`
  Instantiates a new pst file.
  `PstFile(File file, String charset)`
  Instantiates a new pst file.
  `PstFile(String filePath)`
  Instantiates a new pst file.
  `PstFile(String filePath, PstAccess access)`
  Initializes a new instance of the `PstFile` class with the given access mode.
  `PstFile(String filePath, String charset)`
  Instantiates a new pst file.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `close()`
  Close.
  `static PstFile`
  `create(String filePath)`
  Creates a new Unicode PST file with the message store and the default (Outlook) folder structure, opened for editing.
  `String`
  `getCharset()`
  Gets the charset.
  `EncryptionType`
  `getEncryptionType()`
  Gets the encryption type.
  `Folder`
  `getFolder(byte[] entryId)`
  Gets the folder.
  `Folder`
  `getFolder(long id)`
  Gets the folder.
  `Item`
  `getItem(byte[] entryId)`
  Gets the item.
  `Item`
  `getItem(long id)`
  Gets the item.
  `Folder`
  `getMailboxRoot()`
  Gets the mailbox root.
  `MessageStore`
  `getMessageStore()`
  Gets the message store.
  `Folder`
  `getRoot()`
  Gets the root.
  `long`
  `getSize()`
  Gets the size.
  `boolean`
  `is64Bit()`
  Checks if is 64 bit.
  `void`
  `open(File file)`
  Open.
  `void`
  `open(File file, String charset)`
  Open.
  `void`
  `open(String filePath)`
  Open.
  `void`
  `open(String filePath, String charset)`
  Open.
  `void`
  `save()`
  Persists the edits of a store opened for editing (via `create(String)` or `READ_WRITE`) back to its source.
  `void`
  `save(String filePath)`
  Persists the edits of a store opened for editing to the given path.
  `void`
  `setCharset(String charset)`
  Sets the charset.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### PstFile

    public PstFile()
    Instantiates a new pst file.

  - ### PstFile

    public PstFile(String filePath, PstAccess access) throws IOException
    Initializes a new instance of the `PstFile` class with the given access mode. `READ_WRITE` opens the file for in-place editing (changes persisted by `save()`); `READ` opens it read-only.
    Parameters:
      `filePath` - the file path.
      `access` - the access mode.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### PstFile

    public PstFile(String filePath) throws IOException
    Instantiates a new pst file.
    Parameters:
      `filePath` - the file path
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### PstFile

    public PstFile(String filePath, String charset) throws IOException
    Instantiates a new pst file.
    Parameters:
      `filePath` - the file path
      `charset` - the charset
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### PstFile

    public PstFile(File file) throws IOException
    Instantiates a new pst file.
    Parameters:
      `file` - the file
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### PstFile

    public PstFile(File file, String charset) throws IOException
    Instantiates a new pst file.
    Parameters:
      `file` - the file
      `charset` - the charset
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

- ## Method Details

  - ### create

    public static PstFile create(String filePath) throws IOException
    Creates a new Unicode PST file with the message store and the default (Outlook) folder structure, opened for editing. Add user folders and items via `getRoot()`, then call `save()` to persist the changes.
    Parameters:
      `filePath` - the destination file path.
    Returns:
      an editable `PstFile`.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### save

    public void save() throws IOException
    Persists the edits of a store opened for editing (via `create(String)` or `READ_WRITE`) back to its source.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### save

    public void save(String filePath) throws IOException
    Persists the edits of a store opened for editing to the given path.
    Parameters:
      `filePath` - the destination file path.
    Throws:
      `IOException` - if an I/O error occurs.

  - ### open

    public void open(String filePath) throws IOException
    Open.
    Parameters:
      `filePath` - the file path
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### open

    public void open(String filePath, String charset) throws IOException
    Open.
    Parameters:
      `filePath` - the file path
      `charset` - the charset
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### open

    public void open(File file) throws IOException
    Open.
    Parameters:
      `file` - the file
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### open

    public void open(File file, String charset) throws IOException
    Open.
    Parameters:
      `file` - the file
      `charset` - the charset
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### close

    public void close() throws IOException
    Close.
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getFolder

    public Folder getFolder(byte[] entryId) throws IOException
    Gets the folder.
    Parameters:
      `entryId` - the entry id
    Returns:
      the folder
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getFolder

    public Folder getFolder(long id) throws IOException
    Gets the folder.
    Parameters:
      `id` - the id
    Returns:
      the folder
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getItem

    public Item getItem(byte[] entryId) throws IOException
    Gets the item.
    Parameters:
      `entryId` - the entry id
    Returns:
      the item
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### getItem

    public Item getItem(long id) throws IOException
    Gets the item.
    Parameters:
      `id` - the id
    Returns:
      the item
    Throws:
      `IOException` - Signals that an I/O exception has occurred.

  - ### is64Bit

    public boolean is64Bit()
    Checks if is 64 bit.
    Returns:
      true, if is 64 bit

  - ### getSize

    public long getSize()
    Gets the size.
    Returns:
      the size

  - ### getEncryptionType

    public EncryptionType getEncryptionType()
    Gets the encryption type.
    Returns:
      the encryption type

  - ### getMessageStore

    public MessageStore getMessageStore()
    Gets the message store.
    Returns:
      the message store

  - ### getRoot

    public Folder getRoot()
    Gets the root.
    Returns:
      the root

  - ### getMailboxRoot

    public Folder getMailboxRoot()
    Gets the mailbox root.
    Returns:
      the mailbox root

  - ### getCharset

    public String getCharset()
    Gets the charset.
    Returns:
      the charset

  - ### setCharset

    public void setCharset(String charset)
    Sets the charset.
    Parameters:
      `charset` - the new charset