messageLen -= skipLen;
	private static void yamm2Mbox(File box) {		if (box.isDirectory()) {			String[] list = box.list();			for (int i = 0; i < list.length; i++) {				if (!list[i].endsWith(".index")) {					yamm2Mbox(new File(box, list[i]));				}			}		} else {			System.out.println("converting mailbox: " + box);			BufferedInputStream in = null;			BufferedOutputStream out = null;			long newOffset = 0;			long messageLen = 0;			long endPosition = 0;			int skipLen = 1 + File.separator.length();			try {				int BUFFERSIZE = 65536;				byte[] buffer = new byte[BUFFERSIZE];				Index index = new Index(box.toString());				index.open();				in = new BufferedInputStream(new FileInputStream(box));				out = new BufferedOutputStream(new FileOutputStream(box + ".tmp"));				SimpleDateFormat dateFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);				for (int i = 0; i < index.messageNum; i++) {					IndexEntry entry = index.getEntry(i);					if (i+1 < index.messageNum) {						endPosition = index.getEntry(i+1).skip;					} else {						endPosition = box.length();					}					messageLen = endPosition - entry.skip;					messageLen -= skipLen;					entry.skip += newOffset;					index.saveEntry(entry, i);					String blah = "From " + MessageParser.getEmail(entry.from) + " " + dateFormat.format(new Date(entry.date)) + "\n";					newOffset += blah.length() - skipLen;					out.write(blah.getBytes());					while (messageLen > 0) {						int read = in.read(buffer, 0, (int)Math.min(BUFFERSIZE, messageLen));						messageLen -= read;						out.write(buffer, 0, read);					}					in.skip(skipLen);				}				index.rewrite();				index.close();				in.close();				out.close();				box.delete();				new File(box + ".tmp").renameTo(box);			} catch (IOException ioe) {				new ExceptionDialog(					YAMM.getString("msg.error"),					ioe,					YAMM.exceptionNames				);			} finally {				try {					if (in != null) in.close();					if (out != null) out.close();				} catch (IOException ioe) {}			}		}	}