001package edu.wpi.first.wpilibj.networktables2.stream; 002 003import java.io.*; 004 005/** 006 * An IOStream that wraps an {@link InputStream} and an {@link OutputStream} 007 * @author Mitchell 008 * 009 */ 010public class SimpleIOStream implements IOStream{ 011 012 private final InputStream is; 013 private final OutputStream os; 014 015 /** 016 * Create a new SimpleIOStream 017 * @param is 018 * @param os 019 */ 020 public SimpleIOStream(final InputStream is, final OutputStream os){ 021 this.is = is; 022 this.os = os; 023 } 024 025 public InputStream getInputStream() { 026 return is; 027 } 028 029 public OutputStream getOutputStream() { 030 return os; 031 } 032 033 public void close() { 034 try{ 035 is.close(); 036 } catch(IOException e){ 037 //just ignore the error and close the output stream 038 } 039 try{ 040 os.close(); 041 } catch(IOException e){ 042 //just ignore the error and assume everything is now closed 043 } 044 } 045 046}