public class FileOpenSaveDialog
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static javax.swing.JFileChooser |
fileChooser |
private java.awt.Component |
mainUI |
Constructor and Description |
---|
FileOpenSaveDialog(java.awt.Component parentUI,
javax.swing.filechooser.FileFilter fileFilter)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
java.io.File |
openFile()
open a file prompting user to select the file.
|
boolean |
saveFile(byte[] bytes,
java.lang.String extension)
Saves data into a file after the user is prompted to choose the destination.
|
private final java.awt.Component mainUI
private static final javax.swing.JFileChooser fileChooser
public FileOpenSaveDialog(java.awt.Component parentUI, javax.swing.filechooser.FileFilter fileFilter)
parentUI
- the main UI (JFrame) on top of which File open/save dialog should open.fileFilter
- file Filter, null is allowed when no filter is applicable.public boolean saveFile(byte[] bytes, java.lang.String extension) throws java.io.IOException
bytes
- byte array to be saved in a file.java.io.IOException
- if there is an error in creation of the file.public java.io.File openFile() throws java.io.IOException
java.io.IOException
- if there is error in opening the file.