Twitter Update

Using ByteArrayOutputStream in java programming [ Java ]


If we talk about input, there must be output too, here I using bytearrayoutputstream that will save some string in array, then will be output in a file, Here I use notepad. This is the code :



import java.io.*;
public class Main {

    public static void main(String[] args)throws IOException {
      
       String b="albert julius";
       byte c[] = b.getBytes();
       ByteArrayOutputStream d=new ByteArrayOutputStream();
       d.write(c);
       FileOutputStream z = new FileOutputStream("tes.txt");
       d.writeTo(z);
       System.out.println("Write successfully");
       System.out.println("Please check the file that you write....");
       z.close();
       d.close();
    }

}

import java.io.* means is we use all library in java.io.

0 comments:

Post a Comment

ABOUT ME

IP
Albert Julius. Powered by Blogger.
Copyright © Albert'Blog