@@ -0,0 +1,2687 @@
+/*%0A * Copyright 2001-2015 Aspose Pty Ltd. All Rights Reserved.%0A *%0A * This file is part of Aspose.Email. The source code in this file%0A * is only intended as a supplement to the documentation, and is provided%0A * %22as is%22, without warranty of any kind, either expressed or implied.%0A */%0A%0A//This feature is available from Aspose.Email for Java 5.4.0 onwards%0Apackage programmersguide.programmingoutlook.WorkingWithPSTFiles.SplitPSTFiles.Java;%0A%0Aimport com.aspose.email.*;%0A%0Aimport java.io.File;%0A%0Apublic class SplitPSTFiles%0A%7B%0A    static String currentFolder;%0A    static int messageCount;%0A%0A    public static void main(String%5B%5D args) throws Exception%0A    %7B%0A        // The path to the documents directory.%0A        String dataDir = %22src/programmersguide/programmingoutlook/WorkingWithPSTFiles/SplitPSTFiles/Data%22;%0A%0A        // Display Status.%0A        System.out.println(%22MSG file created and saved successfully.%22);%0A    %7D%0A    public void split()%0A    %7B%0A        String path = %22Emailnet_33397%22;%0A        String sourceFileName = dataDir + %22Outlook.pst%22;%0A%0A        final PersonalStorage pst = PersonalStorage.fromFile(sourceFileName);%0A        try /*JAVA: was using*/%0A        %7B%0A            pst.StorageProcessed.add( new StorageProcessedEventHandler() %7B%0A                public void invoke(Object sender, StorageProcessedEventArgs e) %7B%0A                    pstSplit_OnStorageProcessed(sender, e);%0A                %7D%0A            %7D);%0A            pst.ItemMoved.add( new ItemMovedEventHandler() %7B%0A                public void invoke(Object sender, ItemMovedEventArgs e) %7B%0A                    pstSplit_OnItemMoved(sender, e);%0A                %7D%0A            %7D);%0A            pst.splitInto(5000000, dataDir + %22chunks%5C%22);%0A        %7D%0A        finally %7B if (pst != null) (pst).dispose(); %7D%0A    %7D%0A    private void pstSplit_OnStorageProcessed(Object sender, StorageProcessedEventArgs e)%0A    %7B%0A        if (currentFolder != null)%0A        %7B%0A            System.out.println(%22 Added %22 + messageCount + %22 messages to %22 + currentFolder);%0A        %7D%0A%0A        messageCount = 0;%0A        currentFolder = null;%0A        System.out.println(%22*** The chunk is processed: %22 + e.getFileName());%0A    %7D%0A%0A    private void pstSplit_OnItemMoved(Object sender, ItemMovedEventArgs e)%0A    %7B%0A        if (currentFolder == null)%0A        %7B%0A            currentFolder = e.getDestinationFolder().retrieveFullPath();%0A        %7D%0A%0A        String folderPath = e.getDestinationFolder().retrieveFullPath();%0A%0A        if (!folderPath.equals(currentFolder))%0A        %7B%0A            System.out.println(%22 Added %22 + messageCount + %22 messages to %22 + currentFolder);%0A            messageCount = 0;%0A            currentFolder = folderPath;%0A        %7D%0A%0A        messageCount++;%0A    %7D%0A%7D%0A%0A%0A%0A%0A

Split PST File into multiple PST files example