<%@ page import="java.io.*" %>
Writing Binary Data
Writing Binary Data
This page writes binary data to a file.
<%
byte data[] = {1, 2, 3, 4};
String file = application.getRealPath("/") + "test.dat";
FileOutputStream fileoutputstream = new FileOutputStream(file);
for (int i = 0; i < data.length; i++) {
fileoutputstream.write(data[i]);
}
fileoutputstream.close();
%>
Four byte values were written to a file byte by byte.