Initial
This commit is contained in:
48
java/HOTLINK/LOCALS~1.JAV
Normal file
48
java/HOTLINK/LOCALS~1.JAV
Normal file
@@ -0,0 +1,48 @@
|
||||
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
|
||||
{
|
||||
InFile inFile=new InFile(strHostPathFileName,mPathIPFileName);
|
||||
String strServerIP=getServerIP(inFile);
|
||||
inFile.close();
|
||||
return strServerIP;
|
||||
}
|
||||
public String getServerIP(URL resBase)throws Exception
|
||||
{
|
||||
InFile inFile=new InFile(resBase,mPathIPFileName);
|
||||
String strServerIP=getServerIP(inFile);
|
||||
inFile.close();
|
||||
return strServerIP;
|
||||
}
|
||||
private String getServerIP(InFile inFile)throws Exception
|
||||
{
|
||||
String strHost;
|
||||
String strLine;
|
||||
int strLen;
|
||||
|
||||
strLine=new String();
|
||||
strHost=new String();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user