Java Reference
In-Depth Information
L ISTING D.7 Continued
import javax.swing.JFileChooser;
/**
* Appendix D - Implementation of the corresponding JNLP runtime service
*
* @author Mauro Marinilli
* @version 1.0
*/
public class FileSaveServiceImpl implements FileSaveService {
/**
* constructor
*/
public FileSaveServiceImpl() {
}
/**
* open up a save-as dialog
*/
public FileContents saveAsFileDialog(String p1, String[] p2, FileContents fc)
throws java.io.IOException {
JFileChooser jfc = new JFileChooser();
jfc.showSaveDialog(null);
return save(jfc.getSelectedFile(), fc.getInputStream());
}
/**
* open up a save-as dialog
*/
public FileContents saveFileDialog(String p, String[] ignoredParam,
InputStream in, String ignored) throws java.io.IOException {
JFileChooser jfc = new JFileChooser();
jfc.setMultiSelectionEnabled(true);
jfc.showSaveDialog(null);
jfc.setMultiSelectionEnabled(false);
return save(jfc.getSelectedFile(), in);
D
}
/**
* perform the actual file save
*/
private FileContents save(File newFile, InputStream source) {
byte buffer[] = new byte[1024];
int i;
Search WWH ::




Custom Search