示例#1
0
 private void readAllAlbums() throws IOException, CastorException {
   for (File file : IOUtils.getAlbumFiles(this)) {
     AlbumImpl album = readAlbum(file);
     album.addAlbumListener(this);
     albums.put(album.getName(), album);
   }
 }
示例#2
0
 private void writeAlbum(AlbumImpl a_album) throws IOException, CastorException {
   ByteArrayOutputStream bo = new ByteArrayOutputStream();
   GZIPOutputStream gzout = new GZIPOutputStream(bo);
   a_album.createCastorAlbum().write(gzout);
   gzout.flush();
   gzout.close();
   byte[] encodedData = bo.toByteArray();
   File datafile = IOUtils.getAlbumFile(a_album.getName(), ALBUM_EXTENSION);
   OutputStream out = new BufferedOutputStream(new FileOutputStream(datafile));
   for (int i = 0, n = encodedData.length; i < n; i++) {
     out.write(encodedData[i]);
   }
   out.flush();
   out.close();
 }