Skip to content

Commit

Permalink
now works on either files or urls
Browse files Browse the repository at this point in the history
  • Loading branch information
laidig committed May 5, 2017
1 parent e158f07 commit 7a97d40
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
/.idea/
/src/main/resources/njt.pb
/dependency-reduced-pom.xml
/target/
20 changes: 20 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,26 @@
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Expand Down
29 changes: 23 additions & 6 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
import com.google.transit.realtime.*;

import java.net.MalformedURLException;
import java.net.URL;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

public class Main {
static URL url;
public static void main(String[] args){

// Load the file
InputStream stream = null;
try{
File feed = new File("src/main/resources/bart-gtfs-rt.pb");
stream = new FileInputStream(feed);
} catch (Exception e) {
e.printStackTrace();
System.exit(-1);
System.out.println("loading " + args[0]);

if (args[0].startsWith("http")){
try {
url = new URL(args[0]);
stream = url.openStream();
} catch (MalformedURLException e) {
System.out.println("problem with URL " + args[0]);
} catch (IOException e){
e.printStackTrace();
}
} else {

try {
File feed = new File(args[0]);
stream = new FileInputStream(feed);
} catch (Exception e){
System.out.println("Could not load file " + args[0]);
}
}


GtfsRealtime.FeedMessage feedMessage =null;
// Parse file into an object in memory
try {
Expand Down

0 comments on commit 7a97d40

Please sign in to comment.