I still receive a blank screen when I try to print.
my latest modification to print is this....
import java.io.* ;
public class Stackmain
{
// public Stackmain()
// {
// }
public static boolean main(String expression) throws IOException
{
final char LEFT_PARENT = '(';
final char RIGHT_PARENT = ')';
final char LEFT_CURLY = '{';
final char RIGHT_CURLY = '}';
final char LEFT_SQUARE = '[';
final char RIGHT_SQUARE = ']';
Stack s = new Stack(100);
char ch;
int i = 0;
boolean failed = false;
FileInputStream fstream = new FileInputStream("test.txt");
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
while ((ch = (char)br.read()) != (char)-1 )
{
if (!s.full())
{
for (i=0; !failed && (i < expression.length( )); i++)
{
switch (expression.charAt(i))
{
case LEFT_PARENT:
case LEFT_CURLY:
case LEFT_SQUARE:
s.push(expression.charAt(i));
break;
case RIGHT_PARENT:
if (s.empty() || (s.pop() != LEFT_PARENT))
failed = true;
break;
case RIGHT_CURLY:
if (s.empty() || (s.pop() != LEFT_CURLY))
failed = true;
break;
case RIGHT_SQUARE:
if (s.empty() || (s.pop() != LEFT_SQUARE))
failed = true;
break;
}
}
}
}
if (failed == true)
{
System.out.println("Expression does not match");
}
if (failed == false)
{
System.out.println("Expression does match");
}
return (s.empty() && !failed);
}
}