[BugFix] Added check to verify that data can be written to record output stream before writting.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@3449 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/vncviewer/RecordOutputStream.java b/java/src/com/tightvnc/vncviewer/RecordOutputStream.java
index 188695c..a19384e 100644
--- a/java/src/com/tightvnc/vncviewer/RecordOutputStream.java
+++ b/java/src/com/tightvnc/vncviewer/RecordOutputStream.java
@@ -10,15 +10,18 @@
   }
 
   public void write(byte[] b) throws IOException {
-    recordInterface.write(b);
+    if (recordInterface.canWrite())
+      recordInterface.write(b);
   }
 
   public void write(byte[] b, int off, int len) throws IOException {
-    recordInterface.write(b, off, len);
+    if (recordInterface.canWrite())
+      recordInterface.write(b, off, len);
   }
 
   public void write(int b) throws IOException {
-    recordInterface.writeIntBE(b);
+    if (recordInterface.canWrite())
+      recordInterface.writeIntBE(b);
   }
 
   public void writeBoolean(boolean v) { }