Tag Archives: FileStreamProc

Easy Work With File Stream Processing Using Custom Java Class To Store & Retrieve File

Introduction

Oftentimes, application needs to store documents i.e files or images on database record or file copy under specific folder.

Developers use Streaming class i.e OutputStream, InputStream, FileOutputStream, FileInputStream, BufferedOutputStream, BufferedInputStream.
Count of code’s line is a kind of lot. Although there are good examples spread out in a web, sometimes java beginners might get confused.

So, I made custom java class to make file stream processing simple. I call the class with ‘FileStreamProc’. This class can stored documents to database or file via ftp or copy method. Also retrieving documents from data source.
We don’t have to bother anymore about those streaming classes above when we use FileStreamProc class. However, those classes are inside FileStreamProc off course. Main functions of FileStreamProc are Upload, Download, and Delete for storing, retrieving and deleting respectively.
We only have to write 2 lines of codes to store a file to database.
In example of FileStreamProc usage:

FileStreamProc fp = new FileStreamProc("doc1");
fp.Upload("D:\\folder\\SOP.pdf", ProcessMethod.Database);

‘doc1’ refers to document ID value. ‘D:\folder\SOP.pdf’ is file path value. Pretty simple right ?
Continue reading