import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Chunked
{
    public static void main(String[] args) throws Exception
    {
        HttpURLConnection con=(HttpURLConnection)new URL("http://localhost:3000/Test.txt")
                .openConnection();

        con.setChunkedStreamingMode(5);

        con.setDoOutput(true);
        try(OutputStream output=con.getOutputStream())
        {
            output.write("0123456789ABCDE".getBytes());
            output.flush();
        }
    }
}