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

Method open

src/org/opensourcephysics/display/DataFile.java:55–74  ·  view source on GitHub ↗

Opens an xml or data file specified by name. @param fileName the file name

(File file)

Source from the content-addressed store, hash-verified

53 * @param fileName the file name
54 */
55 public void open(File file) {
56 dataList = null;
57 data = null;
58 OSPLog.fine("opening "+file); //$NON-NLS-1$
59 Resource res = new Resource(file);
60 Reader in = res.openReader();
61 String firstLine = readFirstLine(in);
62 // if xml, read the file into an XML control and add tab
63 if(firstLine.startsWith("<?xml")) { //$NON-NLS-1$
64 XMLControlElement control = new XMLControlElement(file);
65 dataList = control.getObjects(Data.class);
66 }
67 // if not xml, attempt to import data and add tab
68 else if(res.getString()!=null) {
69 data = parseData(res.getString(), file.toString());
70 if(data!=null) {
71 }
72 }
73 OSPLog.finest("no data found"); //$NON-NLS-1$
74 }
75
76 /**
77 * Parses character-delimited data from a string. This attempts to extract

Callers 1

DataFileMethod · 0.95

Calls 8

fineMethod · 0.95
openReaderMethod · 0.95
readFirstLineMethod · 0.95
getObjectsMethod · 0.95
getStringMethod · 0.95
parseDataMethod · 0.95
finestMethod · 0.95
toStringMethod · 0.45

Tested by

no test coverage detected