Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

ByteArrayOutputStream

import java.io.ByteArrayOutputStream;

class Main {
  public static void main(String[] args) {

    String data = "This is a line of text inside the string.";

    try {
      // Creates an output stream
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      byte[] array = data.getBytes();

      // Writes data to the output stream
      out.write(array);

      // Retrieves data from the output stream in string format
      String streamData = out.toString();
      System.out.println("Output stream: " + streamData);

      out.close();
    }

    catch(Exception e) {
      e.getStackTrace();
    }
  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: how to add element to dictionary 
Java :: set decimal point in java 
Java :: Java Expression statements 
Java :: constructor of class that extends another class 
Java :: string length java 
Java :: java convert char to charsequence 
Java :: comments java 
Java :: how to set the length to int array in java 
Java :: can abstract class have non abstract methods in java 
Java :: hashmap java 
Java :: array in java 
Java :: new date api in java 8 
Java :: declaring java variables 
Java :: contain java 
Java :: Java forEach() Method 
Java :: string cannot be resolved to a type eclipse 
Java :: |= java operation 
Java :: android videoview not smooth for mp4 
Java :: fragment to activity typecasting 
Java :: Main method not found in class Ponga, please define the main method as: public static void main(String[] args) or a JavaFX application class must extend javafx.application.Application 
Java :: repeat a string in java 
Java :: how to find poiwer in java 
Java :: .code domain 
Java :: how to pass parameters to xsl file 
Java :: java fill in the code to read and store the next value in the array 
Java :: Betrag absolute abs java 
Java :: how to write a perfect shuffle method in java 
Java :: java bter data atual no padrão brasileiro 
Java :: find maximum number of rides in amusement park python 
Java :: final private vs private final 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =