KickJava   Java API By Example, From Geeks To Geeks.

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


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 net.sf.jftp.*;
19 import net.sf.jftp.config.*;
20 import net.sf.jftp.gui.*;
21 import net.sf.jftp.gui.base.UIUtils;
22 import net.sf.jftp.system.logging.Log;
23 import net.sf.jftp.util.*;
24
25 import java.io.*;
26
27
28 public class LoadSet
29 {
30     // private BufferedInputStream in = null;
31
// private String result[] = new String[6];
32
public static String JavaDoc[] loadSet(String JavaDoc file, boolean ask)
33     {
34         try
35         {
36             BufferedReader breader = new BufferedReader(new FileReader(file));
37             String JavaDoc[] result = new String JavaDoc[6];
38             result[0] = breader.readLine();
39             result[1] = breader.readLine();
40             result[2] = breader.readLine();
41             result[3] = breader.readLine();
42             result[4] = breader.readLine();
43             result[5] = breader.readLine();
44
45             if((result[2].equals("") || !Settings.getStorePasswords()) && ask)
46             {
47                 result[2] = UIUtils.getPasswordFromUser(JFtp.statusP.jftp);
48                 Log.debug("fetched: " + result[2] + ", storing: " +
49                           Settings.getStorePasswords());
50             }
51
52             return result;
53         }
54         catch(Exception JavaDoc ex)
55         {
56             // don't need this, occurs if first run
57
//Log.debug(ex.toString() + "@LoadSet::loadSet()");
58
}
59
60         return new String JavaDoc[1];
61     }
62
63     public static String JavaDoc[] loadSet(String JavaDoc file)
64     {
65         return loadSet(file, false);
66     }
67 }
68
Popular Tags