public static boolean writeObjectToFile(Object obj, String filename) {
		try {
			File file = new File(filename);
			File parent = file.getParentFile();
			
			if (parent != null && !parent.exists()) {
				boolean dirsCreated = parent.mkdirs();
				
				if (!dirsCreated) {
					System.out.println("ERROR: Unable to create parent directories for: " + file.getPath());
					return false;
				}
			}
			
			ObjectOutputStream stream = new ObjectOutputStream(new FileOutputStream(file));
			stream.writeObject(obj);
			stream.close();
			return true;
		} catch (IOException e) {
			System.out.println("Exception: " + e.getMessage());
			return false;
		}
	}