Files
Work/java/HOTLINK/INFILE~1.JAV
2024-08-07 09:16:27 -04:00

70 lines
2.0 KiB
Java

import java.net.*;
import java.io.*;
class InFile
{
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
{
open(resBase,strHostPathFileName);
}
public void open(URL resBase,String strHostPathFileName)throws Exception
{
close();
try{mInFile=new URL(resBase,strHostPathFileName);}
catch(Exception 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 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(Exception exception){throw new Exception();}
return mStrLine;
}
public boolean isOkay()
{
return mIsOkay;
}
};
/* 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();
*/