Dillinger4
Nov 18th, 2000, 05:35 PM
How's everybody doing tonight!
This is probably an easy question for some
of you to answer but im not sure of what to do.
If i compile this class i keep getting an "unreported
execption java.io.IOExecption; must be caught or
declared to be thrown.
while((character = bufferedinputstream.read()) != -1)
ok fine i understand that but if i change my main to
public static void main(String[] args) throws IOExecption{
i get cannot resolve symbol.
import java.io.*;
class htmlparser{
public static void main(String[] args){
int character;
int k = 0;
int i = 0;
byte[] hold = "Hello my name is brandon".getBytes();
char[] htmltagholder;
htmltagholder = new char[hold.length]; // htmltagholder array size is set to hold's size
ByteArrayInputStream in = new ByteArrayInputStream(hold);
BufferedInputStream bufferedinputstream = new BufferedInputStream(in);
while((character = bufferedinputstream.read()) != -1) {
if (hold[i] == '<') {
do{
System.arraycopy(hold,i,htmltagholder,k,1);
i++;
k++;
}while(hold[i] != '>');
} // the if statement
}
System.out.println(" The tags in your HTML file are: ");
for(int x = 0; x < htmltagholder.length; x++){
System.out.print(htmltagholder[x]);
}
}
}
This is probably an easy question for some
of you to answer but im not sure of what to do.
If i compile this class i keep getting an "unreported
execption java.io.IOExecption; must be caught or
declared to be thrown.
while((character = bufferedinputstream.read()) != -1)
ok fine i understand that but if i change my main to
public static void main(String[] args) throws IOExecption{
i get cannot resolve symbol.
import java.io.*;
class htmlparser{
public static void main(String[] args){
int character;
int k = 0;
int i = 0;
byte[] hold = "Hello my name is brandon".getBytes();
char[] htmltagholder;
htmltagholder = new char[hold.length]; // htmltagholder array size is set to hold's size
ByteArrayInputStream in = new ByteArrayInputStream(hold);
BufferedInputStream bufferedinputstream = new BufferedInputStream(in);
while((character = bufferedinputstream.read()) != -1) {
if (hold[i] == '<') {
do{
System.arraycopy(hold,i,htmltagholder,k,1);
i++;
k++;
}while(hold[i] != '>');
} // the if statement
}
System.out.println(" The tags in your HTML file are: ");
for(int x = 0; x < htmltagholder.length; x++){
System.out.print(htmltagholder[x]);
}
}
}