X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fuk%2Fac%2Fvamsas%2Fclient%2Fsimpleclient%2FLockedFileOutputStream.java;h=47a66a75f08517e6de74e5240348a0f317ec8d22;hb=1eea4b639911330e7cd65e17c5421cc584f0d22e;hp=178c74d1bf5895ec8fbbaf2417dee89afbfb1326;hpb=5156a824b13ecd091af9f84870f41d83eb59bd71;p=vamsas.git diff --git a/src/uk/ac/vamsas/client/simpleclient/LockedFileOutputStream.java b/src/uk/ac/vamsas/client/simpleclient/LockedFileOutputStream.java index 178c74d..47a66a7 100644 --- a/src/uk/ac/vamsas/client/simpleclient/LockedFileOutputStream.java +++ b/src/uk/ac/vamsas/client/simpleclient/LockedFileOutputStream.java @@ -1,5 +1,23 @@ -/** +/* + * This file is part of the Vamsas Client version 0.2. + * Copyright 2010 by Jim Procter, Iain Milne, Pierre Marguerite, + * Andrew Waterhouse and Dominik Lindner. + * + * Earlier versions have also been incorporated into Jalview version 2.4 + * since 2008, and TOPALi version 2 since 2007. + * + * The Vamsas Client is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * The Vamsas Client is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. * + * You should have received a copy of the GNU Lesser General Public License + * along with the Vamsas Client. If not, see . */ package uk.ac.vamsas.client.simpleclient; @@ -15,22 +33,27 @@ import org.apache.commons.logging.LogFactory; /** * @author Jim - * + * */ public class LockedFileOutputStream extends FileOutputStream { - private static org.apache.commons.logging.Log log = LogFactory.getLog(LockedFileOutputStream.class); - //FileOutputStream ostream=null; - boolean closed=true; + private static org.apache.commons.logging.Log log = LogFactory + .getLog(LockedFileOutputStream.class); + + // FileOutputStream ostream=null; + boolean closed = true; + private void init() { FileChannel ch = super.getChannel(); - if (ch!=null) { - try { closed = !ch.isOpen(); + if (ch != null) { + try { + closed = !ch.isOpen(); } catch (Exception e) { - closed=true; - log.debug("Invalid LockedOutputStream marked closed.",e); + closed = true; + log.debug("Invalid LockedOutputStream marked closed.", e); } } } + /** * @param file * @throws FileNotFoundException @@ -58,7 +81,7 @@ public class LockedFileOutputStream extends FileOutputStream { super(fdObj); init(); if (fdObj.valid()) - closed=false; + closed = false; } /** @@ -80,6 +103,7 @@ public class LockedFileOutputStream extends FileOutputStream { super(name, append); init(); } + /** * closes - actually just flushes the stream instead. */ @@ -90,10 +114,9 @@ public class LockedFileOutputStream extends FileOutputStream { log.debug("Marking Lockedoutputstream closed."); } else throw new IOException("Close on already closed FileOutputStream."); - closed=true; + closed = true; } - /** * @throws IOException * @see java.io.OutputStream#flush() @@ -116,8 +139,6 @@ public class LockedFileOutputStream extends FileOutputStream { return null; } - - /** * @param b * @param off @@ -155,5 +176,5 @@ public class LockedFileOutputStream extends FileOutputStream { else throw new IOException("write on Closed FileOutputStream"); } - + }