From 3bd069a2f19e3df156b95219a5487d9b5323d034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Sun, 23 Jul 2017 15:48:01 -0700 Subject: [PATCH] Fix #30 - Strip BOM from first line of input files (#31) --- .../java/edu/usf/cutr/go_sync/io/GTFSReadIn.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java index 2eda90f1..73b9d90a 100644 --- a/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java +++ b/GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java @@ -38,6 +38,7 @@ public class GTFSReadIn { private List stops; private final String ROUTE_KEY = "route_ref"; private final String NTD_ID_KEY = "ntd_id"; + private static final String UTF8_BOM = "\uFEFF"; private static Hashtable allRoutes; //TODO read agency.txt @@ -136,6 +137,9 @@ public List readBusStop(String fName, String agencyName, String routes_fNa { if (isFirstLine) { isFirstLine = false; + if (thisLine.startsWith(UTF8_BOM)) { + thisLine = thisLine.substring(1); + } OperatorInfo.setGtfsFields(thisLine); thisLine = thisLine.replace("\"", ""); String[] keys = thisLine.split(","); @@ -250,6 +254,9 @@ public Hashtable readRoutes(String routes_fName){ while ((thisLine = br.readLine()) != null) { if (isFirstLine) { isFirstLine = false; + if (thisLine.startsWith(UTF8_BOM)) { + thisLine = thisLine.substring(1); + } thisLine = thisLine.replace("\"", ""); String[] keys = thisLine.split(","); for(int i=0; i> matchRouteToStop(String routes_fName, S while ((thisLine = br.readLine()) != null) { if (isFirstLine) { isFirstLine = false; + if (thisLine.startsWith(UTF8_BOM)) { + thisLine = thisLine.substring(1); + } thisLine = thisLine.replace("\"", ""); String[] keys = thisLine.split(","); for(int i=0; i> matchRouteToStop(String routes_fName, S while ((thisLine = br.readLine()) != null) { if (isFirstLine) { isFirstLine = false; + if (thisLine.startsWith(UTF8_BOM)) { + thisLine = thisLine.substring(1); + } thisLine = thisLine.replace("\"", ""); String[] keys = thisLine.split(","); for(int i=0; i(); // readBusStop("C:\\Users\\Khoa Tran\\Desktop\\Summer REU\\Khoa_transit\\stops.txt"); } -} \ No newline at end of file +}