()
| 353 | } |
| 354 | |
| 355 | public final void saveBookSettings() { |
| 356 | if (chapters != null && bookSettingsFile != null) { |
| 357 | //#debug |
| 358 | AlbiteMIDlet.LOGGER.log("saving book settings"); |
| 359 | try { |
| 360 | ByteArrayOutputStream baos = new ByteArrayOutputStream(2048); |
| 361 | DataOutputStream out = new DataOutputStream(baos); |
| 362 | |
| 363 | try { |
| 364 | out.writeInt(ALBX_MAGIC_NUMBER); |
| 365 | out.writeUTF(currentLanguage); |
| 366 | out.writeShort((short) currentChapter.getNumber()); |
| 367 | |
| 368 | final int chaptersLength = chapters.length; |
| 369 | Chapter chapter; |
| 370 | |
| 371 | out.writeShort((short) chaptersLength); |
| 372 | for (int i = 0; i < chaptersLength; i++) { |
| 373 | chapter = chapters[i]; |
| 374 | out.writeInt(chapter.getCurrentPosition()); |
| 375 | out.writeUTF(chapter.getEncoding()); |
| 376 | } |
| 377 | writeData(baos.toByteArray(), bookSettingsFile); |
| 378 | } finally { |
| 379 | out.close(); |
| 380 | } |
| 381 | } catch (IOException e) { |
| 382 | //#debug |
| 383 | AlbiteMIDlet.LOGGER.log(e); |
| 384 | } catch (SecurityException e) { |
| 385 | //#debug |
| 386 | AlbiteMIDlet.LOGGER.log(e); |
| 387 | } |
| 388 | } |
| 389 | } |
| 390 | |
| 391 | public final void saveBookmarks() { |
| 392 | if (chapters != null && //i.e. if any chapters have been read |
no test coverage detected