Your post lacks information (such as what kind of file) but you can probably achieve it using iText.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.