Initial
This commit is contained in:
75
java/COUNTER/Infile.java
Normal file
75
java/COUNTER/Infile.java
Normal file
@@ -0,0 +1,75 @@
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
|
||||
class InFile
|
||||
{
|
||||
private boolean mIsOkay;
|
||||
private URL mInFile;
|
||||
private URLConnection mConnection;
|
||||
private DataInputStream mInData;
|
||||
private String mStrLine;
|
||||
|
||||
public InFile()
|
||||
{
|
||||
mIsOkay=false;
|
||||
}
|
||||
public InFile(URL resBase,String strHostPathFileName)throws Exception
|
||||
{
|
||||
mIsOkay=false;
|
||||
open(resBase,strHostPathFileName);
|
||||
}
|
||||
public InFile(String strHostPathFileName)throws Exception
|
||||
{
|
||||
mIsOkay=false;
|
||||
open(strHostPathFileName);
|
||||
}
|
||||
public InFile(String resBase,String strHostPathFileName)throws Exception
|
||||
{
|
||||
mIsOkay=false;
|
||||
open(resBase,strHostPathFileName);
|
||||
}
|
||||
public void open(URL resBase,String strHostPathFileName)throws Exception
|
||||
{
|
||||
close();
|
||||
try{mInFile=new URL(resBase,strHostPathFileName);}
|
||||
catch(MalformedURLException exception){throw new Exception();}
|
||||
try{mConnection=mInFile.openConnection();}
|
||||
catch(Exception exception){throw new Exception();}
|
||||
try{mInData=new DataInputStream(mConnection.getInputStream());}
|
||||
catch(Exception exception){throw new Exception();}
|
||||
mIsOkay=true;
|
||||
}
|
||||
public void open(String resBase,String strHostPathFileName)throws Exception
|
||||
{
|
||||
open(resBase+strHostPathFileName);
|
||||
}
|
||||
public void open(String strHostPathFileName)throws Exception
|
||||
{
|
||||
close();
|
||||
try{mInFile=new URL(strHostPathFileName);}
|
||||
catch(MalformedURLException exception){throw new Exception();}
|
||||
try{mConnection=mInFile.openConnection();}
|
||||
catch(IOException ioException){throw new Exception();}
|
||||
try{mInData=new DataInputStream(mConnection.getInputStream());}
|
||||
catch(Exception exception){throw new Exception();}
|
||||
mIsOkay=true;
|
||||
}
|
||||
public void close()
|
||||
{
|
||||
if(!isOkay())return;
|
||||
try{mInData.close();}
|
||||
catch(Exception exception){;}
|
||||
mIsOkay=false;
|
||||
}
|
||||
public String readLine()throws Exception
|
||||
{
|
||||
if(!isOkay())throw new Exception();
|
||||
try{mStrLine=new String(mInData.readLine());}
|
||||
catch(IOException ioException){throw new Exception();}
|
||||
return mStrLine;
|
||||
}
|
||||
public boolean isOkay()
|
||||
{
|
||||
return mIsOkay;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user