~ubuntu-branches/ubuntu/utopic/libjaudiotagger-java/utopic-proposed

« back to all changes in this revision

Viewing changes to org/jaudiotagger/audio/flac/FlacStream.java

  • Committer: Bazaar Package Importer
  • Author(s): Varun Hiremath, Damien Raude-Morvan, Varun Hiremath
  • Date: 2009-04-01 19:17:56 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090401191756-bygniim270guy7o1
Tags: 1.0.9-1
[ Damien Raude-Morvan ]
* New upstream release
* debian/watch: Use java.net repository (which contains new releases!)
* debian/control:
  - Build-Depends on default-jdk-builddep
  - Bump Standards-Version to 3.8.1 (no changes needed)
  - Change section to "java"
* debian/rules: use default-java as JAVA_HOME
* debina/orig-tar.{sh|excludes}: strip audio and others binary files from ZIP
* debian/build.xml:
  - compile with "nowarn" to keep build log readable
  - exclude LogFormatter from build (use com.sun classes)
* debian/ant.properties: new source directory is "src" in orig.tar.gz
* Add myself as Uploaders

[ Varun Hiremath ]
* Accept changes made by Damien Raude-Morvan (Closes: #522130)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
package org.jaudiotagger.audio.flac;
2
 
 
3
 
import org.jaudiotagger.audio.exceptions.CannotReadException;
4
 
 
5
 
import java.io.RandomAccessFile;
6
 
import java.io.IOException;
7
 
 
8
 
/**
9
 
 * Flac Stream
10
 
 * <p/>
11
 
 * Identifies this is in fact a flac stream
12
 
 */
13
 
public class FlacStream
14
 
{
15
 
    public static final int FLAC_STREAM_IDENTIFIER_LENGTH = 4;
16
 
    public static final String FLAC_STREAM_IDENTIFIER = "fLaC";
17
 
 
18
 
    /**
19
 
     * Reads the stream block to ensure it is a flac file
20
 
     * 
21
 
     * @param raf
22
 
     * @throws IOException
23
 
     * @throws CannotReadException
24
 
     */
25
 
    public static void findStream(RandomAccessFile raf)throws IOException,CannotReadException
26
 
    {
27
 
        //Begins tag parsing
28
 
        if (raf.length() == 0)
29
 
        {
30
 
            //Empty File
31
 
            throw new CannotReadException("Error: File empty");
32
 
        }
33
 
        raf.seek(0);
34
 
 
35
 
        //FLAC Stream
36
 
        byte[] b = new byte[FlacStream.FLAC_STREAM_IDENTIFIER_LENGTH];
37
 
        raf.read(b);
38
 
        String flac = new String(b);
39
 
        if (!flac.equals(FlacStream.FLAC_STREAM_IDENTIFIER))
40
 
        {
41
 
            throw new CannotReadException("fLaC Header not found, not a flac file");
42
 
        }
43
 
 
44
 
    }
45
 
}