Miletone

Rp0 / Rp1.000.000

Monday, January 11, 2021

[JAVA] How to read data stream from the any file.

 import java.io.*;


/**

 *

 * @author ANDI

 */

public class JavaStream {


    /**

     * @param args the command line arguments

     */

    public static void main(String[] args) {

        // TODO code application logic here

        //baca stream dari text

        try {

            FileInputStream fstream = new FileInputStream("D:\\File Netbeans\\JavaStream\\src\\stream\\test.txt  ");

            DataInputStream dataInput = new DataInputStream(fstream);

            while(dataInput.available()!=0)

            {

                String data = dataInput.readLine();

                System.out.println(data);

            }

            dataInput.close();

        }

        catch (Exception e) {

            System.err.println("File Input Error");

            }

        }

        

    }

No comments: