/
GYSFlash
/
MonteCarloApp
Обзор
Документация
Войти
/
GYSFlash
/
MonteCarloApp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
src/main/java/org/example/JsonLoader.java
23 строки
789 B
Юрий
first_commit
17 июн 2025, 19:17
17 июн 2025, 19:17
ec7b4c9
Код
Авторство
О чём код?
package org.example; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import java.io.InputStream; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.List; public class JsonLoader { private static final Gson gson = new Gson(); public static List<Point> loadPoints(String resourceName) throws Exception { Type type = new TypeToken<List<Point>>(){}.getType(); try (InputStream is = JsonLoader.class.getClassLoader().getResourceAsStream(resourceName); InputStreamReader reader = new InputStreamReader(is)) { if (is == null) { throw new RuntimeException("Resource not found: " + resourceName); } return gson.fromJson(reader, type); } } }