223 lines
5.0 KiB
Plaintext
223 lines
5.0 KiB
Plaintext
URL mURL;
|
|
String mStrString;
|
|
|
|
try{inFile=new InFile(getCodeBase(),"ip");}
|
|
catch(Exception exception){mStrString=new String("Error creating InFile");return;}
|
|
|
|
while(true)
|
|
{
|
|
try{mStrString=inFile.readLine();}
|
|
catch(Exception exception){break;} //{mStrString=new String("Error reading InFile");break;}
|
|
|
|
|
|
/*
|
|
class Animate extends java.applet.Applet
|
|
{
|
|
URL mURL;
|
|
String mStrString;
|
|
|
|
public Animate()
|
|
{
|
|
}
|
|
public void init()
|
|
{
|
|
InFile inFile;
|
|
|
|
try{inFile=new InFile(getCodeBase(),"ip");}
|
|
catch(Exception exception){mStrString=new String("Error creating InFile");return;}
|
|
|
|
while(true)
|
|
{
|
|
try{mStrString=inFile.readLine();}
|
|
catch(Exception exception){break;} //{mStrString=new String("Error reading InFile");break;}
|
|
repaint();
|
|
}
|
|
repaint();
|
|
}
|
|
public void start()
|
|
{
|
|
}
|
|
public void stop()
|
|
{
|
|
}
|
|
public void run()
|
|
{
|
|
}
|
|
public void paint(Graphics graphics)
|
|
{
|
|
setForeground(Color.red);
|
|
if(null!=mStrString)graphics.drawString(mStrString,20,20);
|
|
}
|
|
}
|
|
*/
|
|
|
|
public gotoServer(URL resBase)throws Exception
|
|
{
|
|
InFile inFile;
|
|
String strHost;
|
|
String strLine;
|
|
int strLen;
|
|
|
|
strHost=new String();
|
|
try{inFile=new InFile(resBase,mPathIPFileName);}
|
|
catch(Exception exception){throw exception;}
|
|
while(true)
|
|
{
|
|
try{strLine=inFile.readLine();}
|
|
catch(Exception exception){break;}
|
|
strLen=strLine.length();
|
|
if(strLen<mMinLength)continue;
|
|
if(0==strLine.substring(0,mMinLength).compareTo(mStrID))
|
|
{
|
|
strHost=strLine.substring(mMinLength+1,strLen-1);
|
|
break;
|
|
}
|
|
}
|
|
if(null==strHost)throw new Exception();
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
FileOutputStream outStream;
|
|
byte byteArray[];
|
|
String strString;
|
|
|
|
|
|
try{outStream=new FileOutputStream("outfile");}
|
|
catch(IOException ioException){return;}
|
|
strString=new String("SEAN");
|
|
|
|
byteArray=new byte[strString.length()];
|
|
|
|
strString.getBytes(0,strString.length(),byteArray,0);
|
|
try{outStream.write(byteArray);}
|
|
catch(IOException ioExeption){return;}
|
|
try{outStream.close();}
|
|
catch(IOException ioExeption){return;}
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/* URL inFile;
|
|
URLConnection connection;
|
|
DataInputStream inData;
|
|
String strLine;
|
|
|
|
try{inFile=new URL(getCodeBase(),"ip");}
|
|
catch(Exception exception){mStrString=new String("Error creating URL");showStatus(mStrString);repaint();return;}
|
|
try{connection=inFile.openConnection();}
|
|
catch(Exception exception){mStrString=new String("Error in URL connection.");showStatus(mStrString);repaint();return;}
|
|
connection.setUseCaches(false);
|
|
try{inData=new DataInputStream(connection.getInputStream());}
|
|
catch(Exception exception){mStrString=new String("Error getting input stream.");showStatus(mStrString);repaint();return;}
|
|
try{strLine=new String(inData.readLine());inData.close();}
|
|
catch(Exception exception){mStrString=new String("Error reading data input stream.");showStatus(mStrString);repaint();return;}
|
|
mStrString=new String(strLine);
|
|
repaint();
|
|
*/
|
|
|
|
|
|
|
|
import java.net.*;
|
|
|
|
class LocalServer
|
|
{
|
|
private final String mPathIPFileName=new String("IP");
|
|
private final String mStrID=new String("[IP]");
|
|
private final int mMinLength=mStrID.length();
|
|
|
|
public LocalServer()
|
|
{
|
|
}
|
|
public String getServerIP(String strHostPathFileName)throws Exception
|
|
{
|
|
return getServerIP(new InFile(strHostPathFileName));
|
|
}
|
|
public String getServerIP(URL resBase)throws Exception
|
|
{
|
|
return getServerIP(new InFile(resBase,mPathIPFileName));
|
|
|
|
/*
|
|
InFile inFile;
|
|
String strHost;
|
|
String strLine;
|
|
int strLen;
|
|
|
|
strLine=new String();
|
|
strHost=new String();
|
|
try{inFile=new InFile(resBase,mPathIPFileName);}
|
|
catch(Exception exception){throw exception;}
|
|
while(true)
|
|
{
|
|
try{strLine=inFile.readLine();}
|
|
catch(Exception exception){return strHost;}
|
|
strLen=strLine.length();
|
|
if(strLen<mMinLength)continue;
|
|
if(0==strLine.substring(0,mMinLength).compareTo(mStrID))
|
|
{
|
|
strHost=strLine.substring(mMinLength+1,strLen-1);
|
|
return strHost;
|
|
}
|
|
}
|
|
*/
|
|
}
|
|
|
|
|
|
|
|
public String getServerIP(InFile inFile)throws Exception
|
|
{
|
|
// InFile inFile;
|
|
String strHost;
|
|
String strLine;
|
|
int strLen;
|
|
|
|
strLine=new String();
|
|
strHost=new String();
|
|
// try{inFile=new InFile(resBase,mPathIPFileName);}
|
|
// catch(Exception exception){throw exception;}
|
|
while(true)
|
|
{
|
|
try{strLine=inFile.readLine();}
|
|
catch(Exception exception){return strHost;}
|
|
strLen=strLine.length();
|
|
if(strLen<mMinLength)continue;
|
|
if(0==strLine.substring(0,mMinLength).compareTo(mStrID))
|
|
{
|
|
strHost=strLine.substring(mMinLength+1,strLen-1);
|
|
return strHost;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// InFile inFile;
|
|
// String strReturn;
|
|
//
|
|
// try{inFile=new InFile(strHostPathFileName,mPathIPFileName);}
|
|
// catch(Exception exception){return new String("open failed for "+strHostPathFileName+mPathIPFileName);}
|
|
// strReturn=new String();
|
|
// try{strReturn=getServerIP(inFile);}
|
|
// catch(Exception exception){return new String("read failed");}
|
|
// return strReturn;
|
|
|
|
|
|
|
|
// String strCodeBase=new String(getCodeBase().toString());
|
|
// strCodeBase=descendLevel(strCodeBase);
|
|
// try{mStrParam=localServer.getServerIP(strCodeBase);}
|
|
// catch(Exception exception){mStrParam="255.255.255.255";}
|
|
|
|
|
|
|
|
|