change datain//outputstream to bufferedIN/OutputStream