MCPcopy Create free account
hub / github.com/dumbledore/AlbiteREADER / saveBookSettings

Method saveBookSettings

src/org/albite/book/model/book/Book.java:355–389  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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

Callers 1

saveBookOptionsMethod · 0.80

Calls 9

getCurrentPositionMethod · 0.95
getEncodingMethod · 0.95
writeDataMethod · 0.95
logMethod · 0.80
writeIntMethod · 0.80
writeShortMethod · 0.80
getNumberMethod · 0.80
toByteArrayMethod · 0.80
closeMethod · 0.45

Tested by

no test coverage detected