public static void ExportPortfolios() throws FileNotFoundException, UnsupportedEncodingException { String filename = "xp.txt"; Iterator it = users.entrySet().iterator(); PrintWriter writer = new PrintWriter(filename, "UTF-8"); while (it.hasNext()) { Map.Entry pair = (Map.Entry) it.next(); writer.print(pair.getKey() + "|" + encrypt((String) pair.getValue())); writer.print("|"); Portfolio p = portfolios.get(pair.getKey()); Map<String, Integer> equitiess = p.getEquities(); Iterator it1 = equitiess.entrySet().iterator(); while (it1.hasNext()) { Map.Entry e = (Map.Entry) it1.next(); writer.print("e," + e.getKey() + "," + e.getValue() + "|"); } Map<String, Account> accountss = p.getAccounts(); Iterator it2 = accountss.entrySet().iterator(); while (it2.hasNext()) { Map.Entry a = (Map.Entry) it2.next(); Date d = ((Account) a.getValue()).getDateAdded(); SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", new Locale("us")); String da = sdf.format(d); writer.print( "a," + ((Account) a.getValue()).getType() + "," + ((Account) a.getValue()).getName() + "," + (((Account) a.getValue()).getInitialAmount() + "," + (((Account) a.getValue()).getCurrentAmount()) + "," + da + "|")); } for (Transaction tr : p.getTrans()) { if (tr.getType().equals("t")) { Date d = tr.getDate(); SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", new Locale("us")); String da = sdf.format(d); writer.print( "t," + tr.getA1() + "," + tr.getA2() + "," + tr.getAmount() + "," + da + "|"); } else { Date d = tr.getDate(); SimpleDateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss Z yyyy", new Locale("us")); String da = sdf.format(d); writer.print( tr.getType() + "," + tr.getEquity().getTicker() + "," + tr.getNumber() + "," + tr.getA1() + da + "|"); } } writer.println(); } writer.close(); }