X-Git-Url: http://git.osdn.net/view?p=mikutoga%2FPmd2XML.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Fjp%2Fsfjp%2Fmikutoga%2Fpmd2xml%2FPmd2Xml.java;h=c0af924c1e792f93a0cdf09a4a2b96fe6b4662e2;hp=c4c4c07fca168c60f9de674e62d3e58f9d18bf53;hb=64234bc48165d5ea1eada99a0b2e056018a8f06e;hpb=2d15979d84813f49e63cf325420998007f3e1074 diff --git a/src/main/java/jp/sfjp/mikutoga/pmd2xml/Pmd2Xml.java b/src/main/java/jp/sfjp/mikutoga/pmd2xml/Pmd2Xml.java index c4c4c07..c0af924 100644 --- a/src/main/java/jp/sfjp/mikutoga/pmd2xml/Pmd2Xml.java +++ b/src/main/java/jp/sfjp/mikutoga/pmd2xml/Pmd2Xml.java @@ -19,8 +19,8 @@ import java.io.OutputStream; import java.io.PrintStream; import java.nio.channels.FileChannel; import java.util.Properties; -import jp.sourceforge.mikutoga.parser.MmdFormatException; -import jp.sourceforge.mikutoga.pmd.IllegalPmdDataException; +import jp.sfjp.mikutoga.bin.parser.MmdFormatException; +import jp.sfjp.mikutoga.pmd.IllegalPmdDataException; import jp.sourceforge.mikutoga.xml.TogaXmlException; import org.xml.sax.SAXException; @@ -217,12 +217,19 @@ public final class Pmd2Xml { if( ! file.exists() ) return; if( ! file.isFile() ) return; - FileOutputStream foStream = new FileOutputStream(file); - FileChannel channnel = foStream.getChannel(); - channnel.truncate(0); + if(file.length() <= 0L) return; - channnel.close(); - foStream.close(); + FileOutputStream foStream = new FileOutputStream(file); + try{ + FileChannel channnel = foStream.getChannel(); + try{ + channnel.truncate(0L); + }finally{ + channnel.close(); + } + }finally{ + foStream.close(); + } return; }