Save and Download byte data from MySQL and PostgreSQL using Java Servlet In this article, we will seen how to convert file to byte array and save into Postgres and Mysql database. After that we also seen how to download saved file in database using file download dialog box. 1. Upload or Save file into database For saving file into database, we will perform following steps : First we will get inputStream from HttpServletRequest and store into InputStream. Convert InputStream to byte array. Store byte array to particular column into database. Using following approach we can Convert InputStream to Byte array in java 1. Using Apache Commons IO library InputStream content = request.getInputStream(); byte[] bytes = IOUtils.toByteArray(content); content.close(); 2. Using ByteArrayOutputStream ByteArrayOutputStream buffer = new ByteArrayOutp...
Welcome To Programming Tutorial. Here i share about Java Programming stuff. I share Java stuff with simple examples.