Wednesday 31 August 2016

Java Tutorial : Java IO (ByteArrayInputStream available method)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=pFtPHkrTKaU&list=UUhwKlOVR041tngjerWxVccw

ByteArrayInputStreamDemo.java
import java.io.ByteArrayInputStream;
import java.io.IOException;

public class ByteArrayInputStreamDemo
{

    public static void main(String[] args) throws IOException
    {
        String str = "Hello World!";
        byte[] byteArray = str.getBytes();
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(byteArray);

        /*
         * Returns: 
         * ------- 
         * 
         * The number of remaining bytes
         * that can be read (or skipped over) from this
         * input stream without blocking.
         * 
         * The value returned is count - pos, which is the
         * number of bytes remaining to be read from the
         * input buffer.
         */
        while (byteArrayInputStream.available() != 0)
        {
            System.out.print(new Character((char) byteArrayInputStream.read()));
        }
    }

}
Output
Hello World!
Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_ByteArrayIS_available_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/JavaIODemo_ByteArrayIS_available_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/d261aab7f0b47dd247e532c02763fe1d7053f5d3/BasicJava/JavaIODemo_ByteArrayIS_available_App/?at=master

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • Kids Tutorial
  • No comments:

    Post a Comment