Here you can find the source of saveObjectToPath(T objectToSave, String pathToSaveTo)
Parameter | Description |
---|---|
objectToSave | The object which should be saved |
pathToSaveTo | The path in which to save the object |
public static <T extends Object> void saveObjectToPath(T objectToSave, String pathToSaveTo)
//package com.java2s; //License from project: Creative Commons License import java.io.*; public class Main { /**/*from w w w . ja v a 2 s. co m*/ * Attempts to write an object to the provided path, creating the file if it does not already * exist. Uses the default serialization methods, and as result, it is recommended that in * Bukkit applications, it be used in conjunction with the Serialization package * * @param objectToSave The object which should be saved * @param pathToSaveTo The path in which to save the object */ public static <T extends Object> void saveObjectToPath(T objectToSave, String pathToSaveTo) { try { ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(pathToSaveTo)); oos.writeObject(objectToSave); oos.close(); } catch (IOException e) { e.printStackTrace(); } } }