Stream Working

Stream:

It is the connection between different source and sink which is used by java for transection of data among source.
e.g to get  inuput from keybord or for accessing file java use Stream
we consider it as a pipeline to connect.

Node stream:
It is used to connect java program to nodes ( figure 1.1 colored yellow)


Figure 1.1

Filter Stream
It is Filter to use extra Stream features.( figure 1.1 colored Green)

Type:
  • Byte Stream
  • Character steam
Byte Stream:
  • FileReader 
  • FIleWriter
Character Stream
  • FIleInputStream
  • FileoutpuStream











import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

import java.io.PrintWriter;
public class Filing {
    
    
    public static void main (String args[]) throws FileNotFoundException
  {
      File f=new File("New.txt");
     System.out.println("Created");
      PrintWriter output= new PrintWriter("New.txt");
      output.print("New file contents");
      output.close();
  Scanner input=new Scanner(new File("New.txt"));
  System.out.println(input.nextLine());
  
  
  }

}

#Book  Y. Daniel Liang 17.2

0 comments:

Post a Comment

My Instagram