()
| 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 |
no test coverage detected