ASF Bugzilla – Attachment 27320 Details for
Bug 51559
ArrayIndexOutOfBoundsException in 3rd party generated MSG file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
code snippet to reproduce error
Test.java (text/x-java), 1.69 KB, created by
b.geisselmeier
on 2011-07-26 10:56:25 UTC
(
hide
)
Description:
code snippet to reproduce error
Filename:
MIME Type:
Creator:
b.geisselmeier
Created:
2011-07-26 10:56:25 UTC
Size:
1.69 KB
patch
obsolete
>import java.io.FileInputStream; >import java.io.IOException; >import java.util.Iterator; > >// TODO: Depencies must be downloaded at the Apache POI project >import org.apache.poi.poifs.filesystem.DirectoryEntry; >import org.apache.poi.poifs.filesystem.DocumentEntry; >import org.apache.poi.poifs.filesystem.DocumentInputStream; >import org.apache.poi.poifs.filesystem.Entry; >import org.apache.poi.poifs.filesystem.POIFSFileSystem; > > >public class Test { > > /** > * No params required... > * @param args > * @throws IOException > */ > public static void main(String[] args) throws IOException { > FileInputStream fis = new FileInputStream("/path/to/mail.msg"); // FIXME > final POIFSFileSystem fs = new POIFSFileSystem(fis); > final DirectoryEntry root = fs.getRoot(); > travers(root); > } > > public static void travers(DirectoryEntry dir) throws IOException { > System.out.println("Traversing " + dir.getName()); > final Iterator<Entry> entries = dir.getEntries(); > while (entries.hasNext()) { > Entry entry = entries.next(); > if (entry.isDirectoryEntry()) { > travers((DirectoryEntry) entry); > } else if(entry.isDocumentEntry()) { > read((DocumentEntry) entry); > } > } > } > > private static void read(DocumentEntry entry) throws IOException { > System.out.print("Read entry " + entry.getName() + ": "); > final DocumentInputStream is = new DocumentInputStream(entry); > byte[] buff = new byte[4096]; > int bytesRead = 0; > int bytesTotal = 0; > while ((bytesRead = is.read(buff)) > 0) { > bytesTotal += bytesRead; > // drop content > } > System.out.println(bytesTotal + " bytes"); > is.close(); > } > >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 51559
:
27319
| 27320