Top Fields Constructors Methods
org.apache.pdfbox.debugger.ui

public Class FileOpenSaveDialog

extends Object
Class Inheritance
Imports
javax.swing.JFileChooser, .JOptionPane, javax.swing.filechooser.FileFilter, java.awt.Component, java.io.File, .IOException, java.nio.file.Files, .Paths, org.apache.pdfbox.pdmodel.PDDocument

Author
Khyrul Bashar A Customized class that helps to open and save file. It uses JFileChooser to operate.

Field Summary

Modifier and TypeField and Description
private static final JFileChooser
private final Component

Constructor Summary

AccessConstructor and Description
public
FileOpenSaveDialog(Component
the main UI (JFrame) on top of which File open/save dialog should open.
parentUI
,
FileFilter
file Filter, null is allowed when no filter is applicable.
fileFilter
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public File

Returns:

the file opened.
openFile
()

open a file prompting user to select the file.

public boolean

Returns:

true if the file is saved successfully or false if failed.
saveDocument
(PDDocument
document to be saved in a .pdf file.
document
,
String
file extension.
extension
)

Saves document into a .pdf file after the user is prompted to choose the destination.

public boolean

Returns:

true if the file is saved successfully or false if failed.
saveFile
(byte[]
byte array to be saved in a file.
bytes
,
String
file extension.
extension
)

Saves data into a file after the user is prompted to choose the destination.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

FILE_CHOOSERback to summary
private static final JFileChooser FILE_CHOOSER
mainUIback to summary
private final Component mainUI

Constructor Detail

FileOpenSaveDialogback to summary
public FileOpenSaveDialog(Component parentUI, FileFilter fileFilter)

Constructor.

Parameters
parentUI:Component

the main UI (JFrame) on top of which File open/save dialog should open.

fileFilter:FileFilter

file Filter, null is allowed when no filter is applicable.

Method Detail

openFileback to summary
public File openFile() throws IOException

open a file prompting user to select the file.

Returns:File

the file opened.

Exceptions
IOException:
if there is error in opening the file.
saveDocumentback to summary
public boolean saveDocument(PDDocument document, String extension) throws IOException

Saves document into a .pdf file after the user is prompted to choose the destination.

Parameters
document:PDDocument

document to be saved in a .pdf file.

extension:String

file extension.

Returns:boolean

true if the file is saved successfully or false if failed.

Exceptions
IOException:
if there is an error in creation of the file.
saveFileback to summary
public boolean saveFile(byte[] bytes, String extension) throws IOException

Saves data into a file after the user is prompted to choose the destination.

Parameters
bytes:byte[]

byte array to be saved in a file.

extension:String

file extension.

Returns:boolean

true if the file is saved successfully or false if failed.

Exceptions
IOException:
if there is an error in creation of the file.