Dark Horse programmers to learn of the tenth day

  Today I want to share what learning is summarized in the tenth day of the dark horse programmers to learn.

  Today I learned IO stream, byte character input and output stream input and output streams, do a few classic case (with a copy video stream of bytes to copy files, folders stream copy single-stage and multi-level folders with the characters, the collection of data written to the file, the read-out set of data files) these are my self, in addition to an array of lecturers work entitled:

A: Analysis of the following requirements, and the code implemented
1. 6 int type keyboard input data number stored in the array arr
2. SUMMARY arr array reversal
3. flipped array subscript 1 is an odd number and exchange exchange 3, 3 and 5 change, so
4. Finally the last array element and an array subscript of an odd subscript of the first switching element is odd
5. Print the final array (steps 1-4 to achieve a after the array)
6: a user input number is six int [1,2,3,4,5,6], the result is the final output [6, 5, 4, 1, 2, 3]

II: Analysis of the following requirements, and the code implemented
1. keyboard input 10 into integers in the array
2. The method defined in one of the odd array on the left, an even number on the right side of the array
3. The definition of a source array and a method of printing the treated array
4. define a method of passing an int type array, this array output appears only once and the digital number

First I start with the self-talk, and I think the focus of IO streams are familiar with how to input and output data:

Byte stream: Because InputSteam is an abstract class, with its subclasses FileInputSteam, OutputSteam is an abstract class, with its subclasses FileOutputSteam  

  FileInputSteam fis = new FileInputSteam(filename);

  FileOutSteam fos = new FileOutSteam(filename);

  byte[] bys = new byte[1024];

  int len;

  while((len=fis.read(bys))!=-1){ fos.write(bys,0,len)} fos.close(); fis.close();

Character stream: Reader is an abstract class, sub-class InputSteamReader, Writer is abstract so subclasses OutputSteamWriter

InputStreamReader byte character stream flowing bridge coded character set may be specified;
the OutputStreamWriter character byte stream flowing bridge may specify coded character set;
Providing simplified character streams: FileReader and FileWriter but their code set by default, if code set specified by the above still require two

  InputSteamReader isr = new InputSteamReader(filename);

  OutputSreamWriter osw =new OutputStreamWriter(filename);

      char[] chs=new char[1024];

      int len;

      while((len=isr.read(chs))!=null){osw.write(chs,0,len);} isr.close(); osw.close;

Buffer :( byte stream input stream buffer) BufferedInputStream bis = new BufferedInputSteam (new FileInputStream (filename));

The character input stream buffer: BufferedReader br = new BufferedReader (new FileReader (filename)); where there is a public Stream <String> readLine () to read a line of data

Note here that the relatively high efficiency of the buffered stream;

 Well, the day of the study are summarized here below for an array of jobs.;

 

An array of work for those of us white is indeed a bit difficult as the first question our strength can do will reverse the array. Want to do it needs a thorough enough understanding of the array

The array subscript flipped an odd number exchange 1 and 3 change, 3 and 5 change, and so on
. Finally, the last array element and a subscript of the array in the first odd subscript for the element exchange odd

Both the need to make a judgment whether the subscript is the number of parity, there is a condition that needs to be done subscript arr.leng-1 must be less than otherwise arr [i + 2] index bounds exception occurs

After doing then determines whether the length of the array is odd, so if the processing is the last odd odd arr [1] and arr [arr.leng-2] exchanged, is even if arr [1] and arr [arr.leng- 1] exchange;

 

Let's look at three questions in front of the second question can also be asked to do it a fourth difficult

<4. A method of passing a defined array of type int, the output of the array and only appears once digital number>

That I was asked to think of a nested for loop, loop the array in turn, is equivalent to the element of the array out and other elements of the array is compared, it defines a counter (count) the initial value of 1, if the content of the element found Like, but not the same angle standard element count ++; at last count == output number to 1;


Learning java is a long and interesting people but also with a little bitter taste of things yesterday and we talked a little buddy class, he said he wanted to give up, too tired autistic, do not want to learn, but also say go out looking for other things to do good and relaxed point, and then I asked him:? you are wealthy people do he smiled and said: No, and I said: No, do not work hard, then who cares for you if? you want to give up, then you can now as early as possible, if to a later stage, you will be very hard to accept, want to go, but it is unfinished, if it continues, they feel that they have not get on, and then I walked out of the classroom. here I also like saying: the best time to plant a tree was a decade ago, followed now. wanted to hold it come on !!!

 

Guess you like

Origin www.cnblogs.com/ydywyx/p/11120354.html