Friday 26 August 2016

Java Tutorial : Java IO (ByteArrayInputStream Capitalize)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=4qHWdI-gcJY&list=UUhwKlOVR041tngjerWxVccw

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

/*
 * Another simple usage of ByteArrayInputStream would be
 * a way of capitalizing the input from the user.
 */

public class ByteArrayInputStreamDemo
{

    public static void main(String[] args) throws IOException
    {
        Scanner scanner = new Scanner(System.in);

        System.out.print("Enter the name : ");
        String name = scanner.nextLine();

        scanner.close();

        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(name.getBytes());

        StringBuilder sb = new StringBuilder();

        int ch;
        while ((ch = byteArrayInputStream.read()) != -1)
        {
            sb.append(Character.toUpperCase((char) ch));
        }
        System.out.println("Your capitalized name: " + sb.toString());

    }
}
Output
Enter the name : peter
Your capitalized name: PETER

Click the below link to download the code:
https://sites.google.com/site/ramj2eev1/home/javabasics/JavaIODemo_ByteArrayIS_Capitilization_App.zip?attredirects=0&d=1

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

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/94d38fdd49b2d33c14c088526d40f902c21a1e0d/BasicJava/JavaIODemo_ByteArrayIS_Capitilization_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
  • 1 comment:

    1. Hi, I read your whole blog. This is very nice. Good to know about the career in qa automation is broad in future. We are also providing various Java Training, anyone interested can Java Training Online for making their career in this field .

      ReplyDelete