Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Fix #25 - Add support for non-ASCII characters #27

Merged
merged 1 commit into from
May 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/GTFSReadIn.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import edu.usf.cutr.go_sync.object.Route;
import edu.usf.cutr.go_sync.object.Stop;
import edu.usf.cutr.go_sync.tools.OsmFormatter;
import java.io.FileInputStream;
import java.io.InputStreamReader;

public class GTFSReadIn {
private List<Stop> stops;
Expand Down Expand Up @@ -127,7 +129,7 @@ public List<Stop> readBusStop(String fName, String agencyName, String routes_fNa
String [] elements;
int stopIdKey=-1, stopNameKey=-1, stopLatKey=-1, stopLonKey=-1;
try {
BufferedReader br = new BufferedReader(new FileReader(fName));
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(fName),"UTF-8"));
boolean isFirstLine = true;
Hashtable keysIndex = new Hashtable();
while ((thisLine = br.readLine()) != null)
Expand Down Expand Up @@ -242,7 +244,7 @@ public Hashtable<String, Route> readRoutes(String routes_fName){
String [] elements;
int routeIdKey=-1, routeShortNameKey=-1;
try {
BufferedReader br = new BufferedReader(new FileReader(routes_fName));
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(routes_fName),"UTF-8"));
boolean isFirstLine = true;
Hashtable keysIndex = new Hashtable();
while ((thisLine = br.readLine()) != null) {
Expand Down Expand Up @@ -314,7 +316,7 @@ public Hashtable<String, HashSet<Route>> matchRouteToStop(String routes_fName, S
// trips.txt read-in
try {
int tripIdKey=-1, routeIdKey=-1;
BufferedReader br = new BufferedReader(new FileReader(trips_fName));
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(trips_fName),"UTF-8"));
boolean isFirstLine = true;
while ((thisLine = br.readLine()) != null) {
if (isFirstLine) {
Expand Down Expand Up @@ -355,7 +357,7 @@ public Hashtable<String, HashSet<Route>> matchRouteToStop(String routes_fName, S
// stop_times.txt read-in
int stopIdKey=-1, tripIdKey = -1;
try {
BufferedReader br = new BufferedReader(new FileReader(stop_times_fName));
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(stop_times_fName),"UTF-8"));
boolean isFirstLine = true;
while ((thisLine = br.readLine()) != null) {
if (isFirstLine) {
Expand Down
8 changes: 4 additions & 4 deletions GO_Sync/src/main/java/edu/usf/cutr/go_sync/io/WriteFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public WriteFile(String fname, String contents) {
Writer output = null;
File file = new File(fname);
try {
output = new BufferedWriter(new FileWriter(file));
output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
output.write(contents);
output.close();
System.out.println("Your file: "+fname+" has been written");
Expand All @@ -64,7 +64,7 @@ public WriteFile(String fname, Hashtable r) {
Writer output = null;
File file = new File(fname);
try {
output = new BufferedWriter(new FileWriter(file));
output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
reportKeys.addAll(report.keySet());
Iterator it = reportKeys.iterator();
int count = 1;
Expand Down Expand Up @@ -223,7 +223,7 @@ public static void exportStops(String fname, Hashtable<String, Stop> r, boolean
Writer output = null;
File file = new File(fname);
try {
output = new BufferedWriter(new FileWriter(file));
output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
//print key (first line)
output.write(OperatorInfo.getGtfsFields());
if(!isGtfsFormat) output.write(",OSM_TAGs");
Expand Down Expand Up @@ -299,7 +299,7 @@ public void writeStopToFile(String fname, List<Stop> st){
Writer output = null;
File file = new File(fname);
try {
output = new BufferedWriter(new FileWriter(file));
output = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(file),"UTF-8"));
output.write("stop_id,stop_name,stop_lat,stop_lon\n");
for(int i=0; i<stops.size(); i++){
output.write(stops.get(i).getStopID()+","+stops.get(i).getStopName()+","+
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ public String sendRequest(String[] hosts, String urlSuffix, String method, Strin
BufferedReader response;
String s;
if(responseCode==HttpURLConnection.HTTP_OK) {
response = new BufferedReader(new InputStreamReader (conn.getInputStream()));
response = new BufferedReader(new InputStreamReader (conn.getInputStream(),"UTF-8"));
char[] cbuf = new char[]{};
response.read(cbuf);
s = response.readLine();
Expand Down