MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / getLogContent

Method getLogContent

CodenameOne/src/com/codename1/io/Log.java:318–345  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

316 ///
317 /// this was practical in old J2ME devices but hasn't been maintained in ages, use sendLog() instead
318 public static String getLogContent() {
319 try {
320 String text = "";
321 if (instance.isFileWriteEnabled()) {
322 if (instance.getFileURL() == null) {
323 instance.setFileURL("file:///" + FileSystemStorage.getInstance().getRoots()[0] + "/codenameOne.log");
324 }
325 Reader r = null; //NOPMD CloseResource
326 try {
327 r = Util.getReader(FileSystemStorage.getInstance().openInputStream(instance.getFileURL()));
328 char[] buffer = new char[1024];
329 int size = r.read(buffer);
330 StringBuilder textBuilder = new StringBuilder();
331 while (size > -1) {
332 textBuilder.append(new String(buffer, 0, size));
333 size = r.read(buffer);
334 }
335 text = textBuilder.toString();
336 } finally {
337 Util.cleanup(r);
338 }
339 }
340 return text;
341 } catch (IOException ex) {
342 ex.printStackTrace();
343 return "";
344 }
345 }
346
347 /// Places a form with the log as a TextArea on the screen, this method can
348 /// be attached to appear at a given time or using a fixed global key. Using

Callers 2

showLogMethod · 0.95
invokeStatic9Method · 0.80

Calls 12

getInstanceMethod · 0.95
getReaderMethod · 0.95
readMethod · 0.95
appendMethod · 0.95
toStringMethod · 0.95
cleanupMethod · 0.95
isFileWriteEnabledMethod · 0.80
getFileURLMethod · 0.80
setFileURLMethod · 0.80
getRootsMethod · 0.80
openInputStreamMethod · 0.65
printStackTraceMethod · 0.45

Tested by

no test coverage detected