1 / 6

What is Java input and output stream?

Java I/O (Input and Output) is used to process the feedback and produce the outcome based on the feedback.<br>Java uses the idea of circulation to make I/O function fast. The java.io package contains all the sessions required for feedback and outcome functions.

prachipatil
Télécharger la présentation

What is Java input and output stream?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What is Java input and output stream? institute of java developer, java course, java course in pune, java developer course in pune, java job, java programming course, java training course, java training in pune,, java training institute in pune java, file java, java compiler, java copy file, java file io, java files,java io, java read file, java stream, java write to file, java.io.file, system.in java file handling in What is Java input and output stream? Java I/O (Input and Output) is used to process the feedback and produce the outcome based on the feedback. Java uses the idea of circulation to make I/O function fast. The java.io package contains all the sessions required for feedback and outcome functions. file handlingin java can be performed by java IO API. Stream A stream is a series of information. In Java stream is comprised of bytes. Like a water flow stream; it is called a stream as it continues with the flow . In java, 3 sources are created for you instantly. All these sources are connected with system. 1) Program.out: conventional output stream 2) Program.in: conventional input stream 3) Program.err: conventional error stream OutputStream Java program uses an outcome circulation to write information to a location, it may be a knowledge file,an range,peripheral system or outlet.

  2. InputStream Java program uses a port circulation to read information from a source, it may be a knowledge file,an range,peripheral system or outlet. OutputStream class OutputStream class is a subjective category.It is the superclass of all sessions comprising an outcome stream of bytes. An output stream allows output bytes and delivers them to some sink. 1) public void write(int)throws IOException: current output stream will contain byte due to this code 2) public void write(byte[])throws IOException: current output stream will contain an array of byte due to this code 3) public void flush()throws IOException: clears out the current output stream 4) public void close()throws IOException: closure of the current output stream InputStream class InputStream class is an subjective category. It is the superclass of all sessions comprising a port stream of bytes. 1) public abstract int read()throws IOException: returns -1 at the end of the file and it reads the next byte of data from the input stream. 2) public int available()throws IOException: number of readable bytes from the current input stream can be estimated 3) public void close()throws IOException: closure of the current input stream Java File Output Stream class Java File Output Stream is an outcome flow for composing information to a data

  3. file. If you have to create basic principles then use FileOutputStream.Instead, for character-oriented information, choose FileWriter.But you can create byte- oriented as well as character-oriented information. Example of Java FileOutputStream class 1. import java.io.*; 2. class Test{ 3. public static void main(String args[]){ 4. try{ 5. FileOutputstream fout=new FileOutputStream(“abc.txt”); 6. String s=”Sachin Tendulkar is my favourite player”; 7. byte b[]=s.getBytes();//converting string into byte array 8. fout.write(b); 9. fout.close(); 10. System.out.println(“success…”); 11. }catch(Exception e){system.out.println(e);} 12. } 13.}

  4. Java File Input Stream class Java File Input Stream category acquires feedback bytes from a data file.It is used for studying sources of raw bytes such as picture information. For studying sources of figures, consider using FileReader. It should be used to study byte-oriented information for example to read picture, sound, movie etc. Example of FileInputStream class 1. import java.io.*; 2. class SimpleRead{ 3. public static void main(String args[]){ 4. try{ 5. FileInputStream fin=new FileInputStream(“abc.txt”); 6. int i=0; 7. while((i=fin.read())!=-1){ 8. System.out.println((char)i); 9. } 10. fin.close(); 11. }catch(Exception e){system.out.println(e);} 12. }

  5. 13.} Example of Reading the information of current Java information file and writing it into another file We can read the information of information file using the File Input Stream class whether it is Java information file, image information file, video information file etc. In this example, we are reading the information of C.java information file and writing it into another information file M.java. import java.io.*; 1. class C{ 2. public static void main(String args[])throws Exception{ 3. FileInputStream fin=new FileInputStream(“C.java”); 4. FileOutputStream fout=new FileOutputStream(“M.java”); 5. int i=0; 6. while((i=fin.read())!=-1){ 7. fout.write((byte)i); 8. } 9. fin.close(); 10.} 11.} You can join the training institute in Java to make your profession in this field.

  6. Java-Reviews of CRB Solutions is sufficient to make you consider and take up a career in this field.

More Related