/** * Saves a snapshot of an image to the users directory * * @param image the image to be saved * @param user the user to save the image to */ public static void SaveProfilePicture(Image image, User user) { String userDir = new File(Persistent.getProfileFilePath(user.getUserId())).getParent(); File file = new File(userDir + "/profile.png"); try { ImageIO.write(SwingFXUtils.fromFXImage(image, null), "png", file); } catch (IOException e) { // file path doesn't exist // System.out.println("Couldn't save picture. filePath not found"); } }
/** * Saves the user profile to a JSON file * * @param user user to be saved */ public static void SaveUser(User user) { String profileString = gson.toJson(user); try { FileWriter writer = new FileWriter(Persistent.getProfileFilePath(user.getUserId())); writer.write(profileString); writer.close(); } catch (IOException e) { // file path doesn't exists // The file path has been set using a file chooser so we will never reach this // e.printStackTrace(); } }