Public classIndex { Public Static voidMain (string[] args) {//To create a file objectFile F1 =NewFile ("src/byte stream _ translated into _ Character stream/text.txt"); File F2=NewFile ("src/byte stream _ translated into _ Character stream/textcopy.txt"); Try ( //Create an input/output stream (java1.7 the code that starts here will automatically close)Reader InputStream =NewInputStreamReader (NewFileInputStream (F1), "GBK"); Writer OutputStream=NewOutputStreamWriter (NewFileOutputStream (F2,true), "GBK"); ){ //declaring buffer arrays Char[] B =New Char[1024]; //declaring the number of byte variables to get intLen =-1; while(len = Inputstream.read (b))! =-1) { //writes the read byte array to the destination fileOutputstream.write (b, 0, Len); } } Catch(Exception e) {//Output Exception InformationE.printstacktrace (); } }}
JAVA IO (byte flow into a character stream)