01: /*
02: * This program is free software; you can redistribute it and/or
03: * modify it under the terms of the GNU General Public License
04: * as published by the Free Software Foundation; either version 2
05: * of the License, or (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10: * GNU General Public License for more details.
11:
12: * You should have received a copy of the GNU General Public License
13: * along with this program; if not, write to the Free Software
14: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15: */
16: package net.sf.jftp.config;
17:
18: import java.io.*;
19:
20: public class SaveSet {
21: private PrintStream out = null;
22:
23: public SaveSet(String file, String host, String user, String pass,
24: String name, String port) {
25: try {
26: FileOutputStream fos;
27: out = new PrintStream((fos = new FileOutputStream(file)));
28: out.println(host);
29: out.println(user);
30:
31: if (Settings.getStorePasswords()) {
32: out.println(pass);
33: } else {
34: out.println("");
35: }
36:
37: out.println(name);
38: out.println(port);
39: fos.close();
40: } catch (Exception ex) {
41: ex.printStackTrace();
42: }
43: }
44:
45: public SaveSet(String file, String host, String user, String pass,
46: String port, String cwd, String lcwd) {
47: try {
48: out = new PrintStream(new FileOutputStream(file));
49: out.println(host);
50: out.println(user);
51:
52: if (Settings.getStorePasswords()) {
53: out.println(pass);
54: } else {
55: out.println("");
56: }
57:
58: out.println(port);
59: out.println(cwd);
60: out.println(lcwd);
61: } catch (Exception ex) {
62: ex.printStackTrace();
63: }
64: }
65:
66: //***
67: //***this is for saving advanced option data
68: //***ideally, we'd have it set up so that common code in
69: //***all of these constructors is put in a private method
70: //*** file: the file name
71: //*** lsCMD: the FTP LIST command to be saved
72: public SaveSet(String file, String lsCmd) {
73: try {
74: out = new PrintStream(new FileOutputStream(file));
75: out.println(lsCmd);
76: } catch (Exception ex) {
77: ex.printStackTrace();
78: }
79: }
80: }
|