/*
 * [TestWriteUTF.java]
 *
 * Summary: Experiment about how WriteUTF stores data.
 *
 * Copyright: (c) 2016-2017 Roedy Green, Canadian Mind Products, http://mindprod.com
 *
 * Licence: This software may be copied and used freely for any purpose but military.
 *          http://mindprod.com/contact/nonmil.html
 *
 * Requires: JDK 1.8+
 *
 * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/
 *
 * Version History:
 *  1.0 2016-03-20 initial version
 */
package com.mindprod.example;

import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;

/**
 * Experiment about how WriteUTF stores data.
 *
 * @author Roedy Green, Canadian Mind Products
 * @version 1.0 2016-03-20 initial version
 * @since 2016-03-20
 */
public final class TestWriteUTF
    {
    /**
     * Test harness
     *
     * @param args not used
     */
    public static void main( String[] args ) throws IOException
        {
        // O P E N  for write
        final File sample = new File( "C:/temp/sample.dat" );
        final FileOutputStream fos = new FileOutputStream( sample );
        final DataOutputStream dos = new DataOutputStream( fos );
        dos.writeUTF( "abc" ); // 00 03 (length) 61 62 63 (ABC)
        dos.writeUTF( "" );  // 00 00 (length)
        //dos.writeUTF( null );  // throws NullPointerException
        dos.close();
        }
    }