Example usage for java.io ObjectOutputStream writeBytes

List of usage examples for java.io ObjectOutputStream writeBytes

Introduction

In this page you can find the example usage for java.io ObjectOutputStream writeBytes.

Prototype

public void writeBytes(String str) throws IOException 

Source Link

Document

Writes a String as a sequence of bytes.

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {

    ObjectOutputStream out = new ObjectOutputStream(
            new BufferedOutputStream(new FileOutputStream("file.data")));
    out.writeBytes("java2s.com");
    out.close();/*www .ja v  a2s.  com*/

    ObjectInputStream in = new ObjectInputStream(new BufferedInputStream(new FileInputStream("file.data")));

    byte[] byteArray = new byte[10];
    in.read(byteArray);
    System.out.println(Arrays.toString(byteArray));
    in.close();
}

From source file:oscar.util.Doc2PDF.java

public static void SavePDF2File(String fileName, String docBin) {

    try {//from  ww w . j  av  a  2 s . c  o  m

        FileOutputStream ostream = new FileOutputStream(fileName);

        ObjectOutputStream p = new ObjectOutputStream(ostream);

        p.writeBytes(docBin);

        p.flush();
        ostream.close();

    } catch (IOException ioe) {
        MiscUtils.getLogger().debug("IO error: " + ioe);
    }
}