📄 configold.java
字号:
/*
* RIC Client 0.6 Release. by Harry Otten (c) Copyright 2002
* Check out http://www.hotten.dds.nl/ric/
*
* The RIC Client needs a RIC Server.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA.
*/
import java.awt.*;
import java.io.*; // for IOException and Input/OutputStream
public class Config {
public Config()
{
}
String HOST;
int HOST_PORT;
String AUTH_REPLY;
String AUTH_QUERY;
FileInputStream in;
public boolean readSettings()
{
File file = new File("RICc.cfg");
if (!file.canRead())
System.out.println("WARNING! Can't read config file RICc.cfg");
else {
try {
in = new FileInputStream(file);
int byteRead;
StringBuffer stringBuf= new StringBuffer();
String commando = new String();
do {
stringBuf.setLength(0);
byteRead = in.read();
do {
// System.out.println("Beginnen " + (char)byteRead);
if (stringBuf.length()==0)
{
// System.out.println("String is leeg");
while (byteRead==13 || byteRead==10)
{
byteRead = in.read();
// System.out.println("TEKEN IN DE LUS: " + byteRead);
}
}
if (byteRead == 35) // check if it is # if so read until next line
{
do
{
byteRead = in.read();
} while (byteRead != 13 && byteRead !=-1);
byteRead = in.read();
// System.out.println("Alles opgegeten na hekje. Nu aanzet: "+byteRead);
}
if (byteRead != 10)
{
// System.out.print("TEKEN KAN ENTER ZIJN: " + byteRead);
stringBuf.append((char)byteRead);
byteRead = in.read();
} else if (stringBuf.length()==0)
byteRead = in.read();
// System.out.println(" TEKENCHECK: " + byteRead);
} while (byteRead != 10 && byteRead !=-1);
commando = stringBuf.toString();
if (commando.startsWith(new String("HOST ")))
{
System.out.println("host config detected");
HOST = commando.substring(7);
System.out.println("host config is:" +HOST);
} else if (commando.startsWith(new String("HOST_PORT")))
{
System.out.println("host port config detected");
HOST_PORT = Integer.parseInt(commando.substring(12,(commando.length()-2)));
System.out.println("host port config is:" +HOST_PORT);
} else if (commando.startsWith(new String("AUTH_QUERY")))
{
System.out.println("auth_query config detected");
AUTH_QUERY = commando.substring(13);
System.out.println("auth_query config is:" +AUTH_QUERY);
} else if (commando.startsWith(new String("AUTH_REPLY")))
{
System.out.println("auth_reply config detected");
AUTH_REPLY = commando.substring(13);
System.out.println("auth_reply config is:" +AUTH_REPLY);
}
} while (byteRead != -1); // so long as byteRead doesn't match endofline
return true;
} catch (Exception e){
System.out.println("Read error config file");
}
}
return false;
}
public String getHost()
{
return HOST;
}
public int getHostPort()
{
return HOST_PORT;
}
public String getAuthReply()
{
return AUTH_REPLY;
}
public String getAuthQuery()
{
return AUTH_QUERY;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -