KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > jftp > config > SaveSet


1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * 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
21 public class SaveSet
22 {
23     private PrintStream out = null;
24
25     public SaveSet(String JavaDoc file, String JavaDoc host, String JavaDoc user, String JavaDoc pass,
26                    String JavaDoc name, String JavaDoc port)
27     {
28         try
29         {
30             FileOutputStream fos;
31             out = new PrintStream((fos = new FileOutputStream(file)));
32             out.println(host);
33             out.println(user);
34
35             if(Settings.getStorePasswords())
36             {
37                 out.println(pass);
38             }
39             else
40             {
41                 out.println("");
42             }
43
44             out.println(name);
45             out.println(port);
46             fos.close();
47         }
48         catch(Exception JavaDoc ex)
49         {
50             ex.printStackTrace();
51         }
52     }
53
54     public SaveSet(String JavaDoc file, String JavaDoc host, String JavaDoc user, String JavaDoc pass,
55                    String JavaDoc port, String JavaDoc cwd, String JavaDoc lcwd)
56     {
57         try
58         {
59             out = new PrintStream(new FileOutputStream(file));
60             out.println(host);
61             out.println(user);
62
63             if(Settings.getStorePasswords())
64             {
65                 out.println(pass);
66             }
67             else
68             {
69                 out.println("");
70             }
71
72             out.println(port);
73             out.println(cwd);
74             out.println(lcwd);
75         }
76         catch(Exception JavaDoc ex)
77         {
78             ex.printStackTrace();
79         }
80     }
81
82     //***
83
//***this is for saving advanced option data
84
//***ideally, we'd have it set up so that common code in
85
//***all of these constructors is put in a private method
86
//*** file: the file name
87
//*** lsCMD: the FTP LIST command to be saved
88
public SaveSet(String JavaDoc file, String JavaDoc lsCmd)
89     {
90         try
91         {
92             out = new PrintStream(new FileOutputStream(file));
93             out.println(lsCmd);
94         }
95         catch(Exception JavaDoc ex)
96         {
97             ex.printStackTrace();
98         }
99     }
100 }
101
Popular Tags