Commits

Jerry Lee  committed 156eda1

adjust package

  • Participants
  • Parent commits 4fb59b6

Comments (0)

Files changed (6)

File src/test/java/com/oldratlee/io/demo/Demo_FileTransport.java

 import java.io.File;
 import java.io.IOException;
 
+import com.oldratlee.io.utils.Inputs;
+import com.oldratlee.io.utils.Outputs;
+
 
 /**
  * @author oldratlee

File src/test/java/com/oldratlee/io/demo/Demo_Intercept_Counter.java

 import com.oldratlee.io.core.Output;
 import com.oldratlee.io.core.filter.Filters;
 import com.oldratlee.io.core.filter.Function;
+import com.oldratlee.io.utils.Inputs;
+import com.oldratlee.io.utils.Outputs;
 
 /**
  * @author oldratlee

File src/test/java/com/oldratlee/io/demo/Inputs.java

-package com.oldratlee.io.demo;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-
-import com.oldratlee.io.core.Input;
-import com.oldratlee.io.core.Output;
-import com.oldratlee.io.core.Receiver;
-import com.oldratlee.io.core.Sender;
-
-/**
- * @author oldratlee
- */
-public class Inputs {
-    
-    static class TextInput implements Input<String, IOException> {
-        final File source;
-        final BufferedReader reader;
-        final TextSender sender; 
-        
-        public TextInput(File source) throws IOException {
-            this.source = source;
-            reader = new BufferedReader(new FileReader(source));
-            sender = new TextSender(reader);
-        }
-        
-        public <ReceiverThrowableType extends Throwable> void transferTo(Output<String, ReceiverThrowableType> output)
-                throws IOException, ReceiverThrowableType {
-            output.receiveFrom(sender);
-            
-            try {
-                reader.close();
-            } catch (Exception e) {
-                // ignore close exception :)
-            }
-        }
-        
-    }
-    
-    static class TextSender implements Sender<String, IOException> {
-        final BufferedReader reader;
-        
-        public TextSender(BufferedReader reader) throws FileNotFoundException {
-            this.reader = reader;
-        }
-
-        public <ReceiverThrowableType extends Throwable> void sendTo(Receiver<String, ReceiverThrowableType> receiver)
-                throws ReceiverThrowableType, IOException {
-            String readLine;
-            while((readLine = reader.readLine()) != null) {
-                receiver.receive(readLine + "\n");
-            }
-        }
-    }
-    
-    public static Input<String, IOException> text(File source) throws IOException {
-        return new TextInput(source);
-    }
-}

File src/test/java/com/oldratlee/io/demo/Outputs.java

-package com.oldratlee.io.demo;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
-
-import com.oldratlee.io.core.Output;
-import com.oldratlee.io.core.Receiver;
-import com.oldratlee.io.core.Sender;
-
-/**
- * @author oldratlee
- */
-public class Outputs {
-    static class TextOutput implements Output<String, IOException> {
-        final File destination;
-        final Writer writer;
-        final TextFileReceiver receiver;
-
-        public TextOutput(File destination) throws IOException {
-            this.destination = destination;
-            writer = new FileWriter(destination);
-            receiver = new TextFileReceiver(writer);
-        }
-
-        public <SenderThrowableType extends Throwable> void receiveFrom(Sender<String, SenderThrowableType> sender)
-                throws IOException, SenderThrowableType {
-            sender.sendTo(receiver);
-            receiver.close();
-            try {
-                writer.close();
-            } catch (Exception e) {
-                // ignore writer exception!
-            }
-        }
-    }
-
-    static class TextFileReceiver implements
-            Receiver<String, IOException> {
-        final Writer writer;
-
-        public TextFileReceiver(Writer writer) throws IOException {
-            this.writer = writer;
-        }
-
-        public void receive(String item) throws IOException {
-            writer.write(item);
-        }
-
-        public void close() throws IOException {
-        }
-    }
-
-    public static Output<String, IOException> text(File destination) throws IOException {
-        return new TextOutput(destination);
-    }
-}

File src/test/java/com/oldratlee/io/utils/Inputs.java

+package com.oldratlee.io.utils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+
+import com.oldratlee.io.core.Input;
+import com.oldratlee.io.core.Output;
+import com.oldratlee.io.core.Receiver;
+import com.oldratlee.io.core.Sender;
+
+/**
+ * @author oldratlee
+ */
+public class Inputs {
+    
+    static class TextInput implements Input<String, IOException> {
+        final File source;
+        final BufferedReader reader;
+        final TextSender sender; 
+        
+        public TextInput(File source) throws IOException {
+            this.source = source;
+            reader = new BufferedReader(new FileReader(source));
+            sender = new TextSender(reader);
+        }
+        
+        public <ReceiverThrowableType extends Throwable> void transferTo(Output<String, ReceiverThrowableType> output)
+                throws IOException, ReceiverThrowableType {
+            output.receiveFrom(sender);
+            
+            try {
+                reader.close();
+            } catch (Exception e) {
+                // ignore close exception :)
+            }
+        }
+        
+    }
+    
+    static class TextSender implements Sender<String, IOException> {
+        final BufferedReader reader;
+        
+        public TextSender(BufferedReader reader) throws FileNotFoundException {
+            this.reader = reader;
+        }
+
+        public <ReceiverThrowableType extends Throwable> void sendTo(Receiver<String, ReceiverThrowableType> receiver)
+                throws ReceiverThrowableType, IOException {
+            String readLine;
+            while((readLine = reader.readLine()) != null) {
+                receiver.receive(readLine + "\n");
+            }
+        }
+    }
+    
+    public static Input<String, IOException> text(File source) throws IOException {
+        return new TextInput(source);
+    }
+}

File src/test/java/com/oldratlee/io/utils/Outputs.java

+package com.oldratlee.io.utils;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.Writer;
+
+import com.oldratlee.io.core.Output;
+import com.oldratlee.io.core.Receiver;
+import com.oldratlee.io.core.Sender;
+
+/**
+ * @author oldratlee
+ */
+public class Outputs {
+    static class TextOutput implements Output<String, IOException> {
+        final File destination;
+        final Writer writer;
+        final TextFileReceiver receiver;
+
+        public TextOutput(File destination) throws IOException {
+            this.destination = destination;
+            writer = new FileWriter(destination);
+            receiver = new TextFileReceiver(writer);
+        }
+
+        public <SenderThrowableType extends Throwable> void receiveFrom(Sender<String, SenderThrowableType> sender)
+                throws IOException, SenderThrowableType {
+            sender.sendTo(receiver);
+            receiver.close();
+            try {
+                writer.close();
+            } catch (Exception e) {
+                // ignore writer exception!
+            }
+        }
+    }
+
+    static class TextFileReceiver implements
+            Receiver<String, IOException> {
+        final Writer writer;
+
+        public TextFileReceiver(Writer writer) throws IOException {
+            this.writer = writer;
+        }
+
+        public void receive(String item) throws IOException {
+            writer.write(item);
+        }
+
+        public void close() throws IOException {
+        }
+    }
+
+    public static Output<String, IOException> text(File destination) throws IOException {
+        return new TextOutput(destination);
+    }
+}