X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosStateIterable.java;h=6202f9705613f189391cdf329424bb876f3b5d05;hp=be812095342988dc6f2f889f74d4f2bda5a9cff1;hb=f822b84d8c25159ff113fef6a419b6e18e87a87a;hpb=f0216d721ed13f4d3dc608bb6ad8f83732b27c0a diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java index be812095..6202f970 100644 --- a/altoslib/AltosStateIterable.java +++ b/altoslib/AltosStateIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_4; +package org.altusmetrum.altoslib_7; import java.io.*; import java.util.*; @@ -26,4 +26,18 @@ public abstract class AltosStateIterable implements Iterable { } public abstract void write(PrintStream out); + + public static AltosStateIterable iterable(File file) { + FileInputStream in; + try { + in = new FileInputStream(file); + } catch (Exception e) { + System.out.printf("Failed to open file '%s'\n", file); + return null; + } + if (file.getName().endsWith("telem")) + return new AltosTelemetryFile(in); + else + return new AltosEepromFile(in); + } }