public static void writeToFile(Collection<UserEntity> col) throws IOException {
        String webRoot = Utils.getWebRoot();//this.getServletConfig().getServletContext().getRealPath("/");
        File file = new File(webRoot + "account.txt");
        PrintWriter writer = new PrintWriter(new FileOutputStream(file));
        try {
            UserEntity user = null;
            String line = null;
            Iterator<UserEntity> it = col.iterator();
            writer.write("#username=password:receiveMsgEmail\r\n");
            while (it.hasNext()) {
                user = it.next();
                line = String.format("%1$s=%2$s:%3$s", user.getUsername(), user.getPassword(), user.getEmail());
                writer.write(line + "\r\n");
            }
        } finally{
            writer.close();
        }
    }