MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / main

Method main

src/csm/ch03/DataLoaderApp.java:23–38  ·  view source on GitHub ↗

Starts the Java application. @param args command line parameters

(String[] args)

Source from the content-addressed store, hash-verified

21 * @param args command line parameters
22 */
23 public static void main(String[] args) {
24 String fileName = "falling.txt"; // reads from directory where DataLoaderApp is located
25 // gets the data file
26 Resource res = ResourceLoader.getResource(fileName, DataLoaderApp.class);
27 String data = res.getString();
28 String[] lines = data.split("\n"); // split string on newline character
29 // extract x-y data from every line
30 for(int i = 0, n = lines.length;i<n;i++) {
31 if(lines[i].trim().startsWith("//")) {
32 continue; // skip comment lines
33 }
34 String[] numbers = lines[i].trim().split("\\s"); // split on any white space
35 System.out.print("t = "+numbers[0]);
36 System.out.println(" y = "+numbers[1]);
37 }
38 }
39}
40
41/*

Callers

nothing calls this directly

Calls 5

getResourceMethod · 0.95
getStringMethod · 0.95
printMethod · 0.65
printlnMethod · 0.65
trimMethod · 0.45

Tested by

no test coverage detected