Example usage for java.io InvalidObjectException toString

List of usage examples for java.io InvalidObjectException toString

Introduction

In this page you can find the example usage for java.io InvalidObjectException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:org.sakaiproject.content.chh.file.ContentHostingHandlerImplFileSystem.java

private synchronized void removeProperties(ContentEntityFileSystem cefs) {
    String propFileName = getPropertiesFileName(cefs);
    BufferedReader r = null;/*from w ww  . ja  v a2  s. c  o  m*/
    Writer w = null;
    // Algorithm: copy properties from old file for everything except this filename;
    //            rename new properties file on top of old one.
    String fileIdPrefix = cefs.basePath + propertiesFileFieldSeparator + cefs.relativePath
            + propertiesFileFieldSeparator;
    try {
        w = new BufferedWriter(new FileWriter(propFileName + ".new"));
        try {
            r = new BufferedReader(new FileReader(propFileName));
            String line = null;
            while ((line = r.readLine()) != null)
                if (!line.startsWith(fileIdPrefix))
                    w.write(line + "\n");
            r.close();
        } catch (InvalidObjectException e) {
            /* file doesn't exist / unreadable -- ignore */} catch (FileNotFoundException e) {
            /* file doesn't exist / unreadable -- ignore */}

        // move new file over old one
        w.flush();
        w.close();
        new File(propFileName).delete();
        new File(propFileName + ".new").renameTo(new File(propFileName));
    } catch (IOException e) {
        log.warn("Content Hosting Handler File System was unable to remove Sakai properties: " + e.toString());
    } finally {
        if (w != null)
            try {
                w.flush();
                w.close();
            } catch (Exception e) {
            }
        if (r != null)
            try {
                r.close();
            } catch (Exception e) {
            }
        r = null;
        w = null;
    }
}