Package entagged.audioformats.exceptions

Examples of entagged.audioformats.exceptions.CannotWriteException


  public void deleteTag(AudioFile f) throws CannotWriteException {
    String ext = Utils.getExtension(f);

    Object afw = writers.get(ext);
    if (afw == null)
      throw new CannotWriteException(
          "No Deleter associated to this extension: " + ext);

    ((AudioFileWriter) afw).delete(f);
  }
View Full Code Here


  public void writeFile(AudioFile f) throws CannotWriteException {
    String ext = Utils.getExtension(f);

    Object afw = writers.get(ext);
    if (afw == null)
      throw new CannotWriteException(
          "No Writer associated to this extension: " + ext);

    ((AudioFileWriter) afw).write(f);
  }
View Full Code Here

            }
            createModifiedCopy(new GenericTag(), header, raf, tempRaf, true);
        } catch (IOException ioe) {
            throw ioe;
        } catch (Exception cre) {
            throw new CannotWriteException(
                    "Cannot modify tag because exception occured:\n   "
                            + cre.getMessage());
        }
    }
View Full Code Here

            }
            createModifiedCopy(tag, header, raf, rafTemp, false);
        } catch (IOException ioe) {
            throw ioe;
        } catch (Exception cre) {
            throw new CannotWriteException(
                    "Cannot modify tag because exception occured:\n   "
                            + cre.getMessage());
        }
    }
View Full Code Here

   * @exception CannotWriteException
   *                if anything went wrong
   */
  public synchronized void delete(AudioFile f) throws CannotWriteException {
    if (!f.canWrite())
      throw new CannotWriteException("Can't write to file \""
          + f.getAbsolutePath() + "\"");

    if (f.length() <= 150)
      throw new CannotWriteException("Less than 150 byte \""
          + f.getAbsolutePath() + "\"");

    RandomAccessFile raf = null;
    RandomAccessFile rafTemp = null;
    File tempF = null;
    // Will be set to true on VetoException, causing the finally block to
    // discard
    // the tempfile.
    boolean revert = false;
    try {

      tempF = File.createTempFile("entagged", ".tmp", f.getParentFile());
      rafTemp = new RandomAccessFile(tempF, "rw");
      raf = new RandomAccessFile(f, "rw");
      raf.seek(0);
      rafTemp.seek(0);

      try {
        if (this.modificationListener != null) {
          this.modificationListener.fileWillBeModified(f, true);
        }
        deleteTag(raf, rafTemp);
        if (this.modificationListener != null) {
          this.modificationListener.fileModified(f, tempF);
        }
      } catch (ModifyVetoException veto) {
        throw new CannotWriteException(veto);
      }

    } catch (Exception e) {
      revert = true;
      throw new CannotWriteException("\"" + f.getAbsolutePath() + "\" :"
          + e, e);
    } finally {
      // will be set to the remaining file.
      File result = f;
      try {
View Full Code Here

      delete(af);
      return;
    }

    if (!af.canWrite())
      throw new CannotWriteException("Can't write to file \""
          + af.getAbsolutePath() + "\"");

    if (af.length() <= 150)
      throw new CannotWriteException("Less than 150 byte \""
          + af.getAbsolutePath() + "\"");

    RandomAccessFile raf = null;
    RandomAccessFile rafTemp = null;
    File tempF = null;
    // Will be set to true in exception block to not replace original file.
    boolean cannotWrite = false;
    try {

      tempF = File.createTempFile("entagged", ".tmp", af.getParentFile());
      rafTemp = new RandomAccessFile(tempF, "rw");
      raf = new RandomAccessFile(af, "rw");
      raf.seek(0);
      rafTemp.seek(0);
      try {
        if (this.modificationListener != null) {
          this.modificationListener.fileWillBeModified(af, false);
        }
        writeTag(af.getTag(), raf, rafTemp);
        if (this.modificationListener != null) {
          this.modificationListener.fileModified(af, tempF);
        }
      } catch (ModifyVetoException veto) {
        throw new CannotWriteException(veto);
      }
    } catch (Exception e) {
      cannotWrite = true;
      throw new CannotWriteException("\"" + af.getAbsolutePath() + "\" :"
          + e);
    } finally {
      File result = af;
      try {
        if (raf != null)
View Full Code Here

TOP

Related Classes of entagged.audioformats.exceptions.CannotWriteException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.