public Mime4jParserIterator()

in mail-archive/server/src/main/java/org/apache/sling/mailarchiveserver/impl/Mime4jMboxParserImpl.java [58:91]


		public Mime4jParserIterator(InputStream is) throws IOException {
			File tempFile = null;
			FileOutputStream fileOS = null;
			try {
				// create temp file
				tempFile = File.createTempFile("MAS_", ".mbox");
				tempFileAbsPath = tempFile.getAbsolutePath();
				fileOS = new FileOutputStream(tempFile);
				FileChannel fileChannel = fileOS.getChannel();
				byte[] buffer = new byte[BUFFER_SIZE];
				int read = 0;
				while ((read = is.read(buffer)) != -1) {
					ByteBuffer buf2 = MailArchiveServerConstants.DEFAULT_ENCODER.encode(CharBuffer.wrap(new String(buffer, 0, read)));
					fileChannel.write(buf2);
				}
				fileChannel.close();


				createMboxIterator(tempFile);
			} finally {
				if (tempFile.exists()) {
					tempFile.delete();
					tempFile = null;
				}
				if (fileOS != null) {
					fileOS.close();
					fileOS = null;
				}
				if (is != null) {
					is.close();
					is = null;
				}
			}
		}