[Patchanim-commit] SF.net SVN: patchanim: [39] trunk/patchanim/src/com/mebigfatguy/patchanim
Brought to you by:
dbrosius
|
From: <dbr...@us...> - 2008-01-27 22:29:20
|
Revision: 39
http://patchanim.svn.sourceforge.net/patchanim/?rev=39&view=rev
Author: dbrosius
Date: 2008-01-27 14:29:19 -0800 (Sun, 27 Jan 2008)
Log Message:
-----------
start adding io routines
Added Paths:
-----------
trunk/patchanim/src/com/mebigfatguy/patchanim/io/
trunk/patchanim/src/com/mebigfatguy/patchanim/io/Closer.java
trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java
Added: trunk/patchanim/src/com/mebigfatguy/patchanim/io/Closer.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/io/Closer.java (rev 0)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/Closer.java 2008-01-27 22:29:19 UTC (rev 39)
@@ -0,0 +1,18 @@
+package com.mebigfatguy.patchanim.io;
+
+import java.io.Closeable;
+import java.io.IOException;
+
+public class Closer {
+
+ private Closer() {
+ }
+
+ public static void close(Closeable c) {
+ try {
+ if (c != null)
+ c.close();
+ } catch (IOException ioe) {
+ }
+ }
+}
Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/io/Closer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Added: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java
===================================================================
--- trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java (rev 0)
+++ trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java 2008-01-27 22:29:19 UTC (rev 39)
@@ -0,0 +1,46 @@
+package com.mebigfatguy.patchanim.io;
+
+import java.beans.XMLDecoder;
+import java.beans.XMLEncoder;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import com.mebigfatguy.patchanim.PatchAnimDocument;
+
+public class PatchAnimIO {
+
+ private PatchAnimIO() {
+
+ }
+
+ public static void saveFile(File f, PatchAnimDocument document) throws IOException {
+ OutputStream os = null;
+ try {
+ os = new BufferedOutputStream(new FileOutputStream(f));
+ XMLEncoder encoder = new XMLEncoder(os);
+ encoder.writeObject(document);
+ encoder.flush();
+ } finally {
+ Closer.close(os);
+ }
+ }
+
+ public static PatchAnimDocument loadFile(File f) throws IOException {
+ InputStream is = null;
+ try {
+ is = new BufferedInputStream(new FileInputStream(f));
+ XMLDecoder decoder = new XMLDecoder(is);
+ return (PatchAnimDocument)decoder.readObject();
+ } finally {
+ Closer.close(is);
+ }
+ }
+
+
+}
Property changes on: trunk/patchanim/src/com/mebigfatguy/patchanim/io/PatchAnimIO.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|