[ADD] loaders and fileio read
This commit is contained in:
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -14,21 +15,20 @@ import java.nio.file.Paths;
|
||||
|
||||
public class FileIO<T> {
|
||||
|
||||
private Class<T> tClass;
|
||||
|
||||
|
||||
public Class<T> readFileData(Context context, String fileName) {
|
||||
Gson gson = new Gson();
|
||||
AssetManager am = context.getAssets();
|
||||
Class<T> res = null;
|
||||
try {
|
||||
InputStream is = am.open(fileName);
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(is);
|
||||
T res = gson.fromJson(inputStreamReader,);
|
||||
res = gson.fromJson(inputStreamReader,new TypeToken<T>(){}.getType());
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//TODO make
|
||||
return null;
|
||||
return res;
|
||||
}
|
||||
|
||||
public void writeFileData(T objectToWrite) {
|
||||
|
||||
Reference in New Issue
Block a user