MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / openTextFile

Method openTextFile

ij/src/main/java/ij/plugin/URLOpener.java:141–167  ·  view source on GitHub ↗
(String urlString, boolean install)

Source from the content-addressed store, hash-verified

139 }
140
141 void openTextFile(String urlString, boolean install) {
142 StringBuffer sb = null;
143 try {
144 URL url = new URL(urlString);
145 InputStream in = url.openStream();
146 BufferedReader br = new BufferedReader(new InputStreamReader(in));
147 sb = new StringBuffer() ;
148 String line;
149 while ((line=br.readLine()) != null)
150 sb.append (line + "\n");
151 in.close ();
152 } catch (IOException e) {
153 if (!(install&&urlString.endsWith("StartupMacros.txt")))
154 IJ.error("URL Opener", ""+e);
155 sb = null;
156 }
157 if (sb!=null) {
158 if (install)
159 (new MacroInstaller()).install(new String(sb));
160 else {
161 int index = urlString.lastIndexOf("/");
162 if (index!=-1 && index<=urlString.length()-1)
163 urlString = urlString.substring(index+1);
164 (new Editor()).create(urlString, new String(sb));
165 }
166 }
167 }
168
169 private void cacheSampleImages() {
170 String[] names = getSampleImageNames();

Callers 1

runMethod · 0.95

Calls 8

errorMethod · 0.95
substringMethod · 0.80
appendMethod · 0.65
closeMethod · 0.65
lengthMethod · 0.65
readLineMethod · 0.45
installMethod · 0.45
createMethod · 0.45

Tested by

no test coverage detected