char buf[] = new char[s.length()];
s.getChars(0, s.length(), buf, 0);
CharArrayReader in = new CharArrayReader(buf);
PushbackReader f = new PushbackReader(in);
int c;
while ((c = f.read()) != -1) {
switch(c) {
case '=':
if ((c = f.read()) == '=')
System.out.print(".eq.");
else {
System.out.print("<-");
f.unread(c);
}
break;
default:
System.out.print((char) c);
break;
}
}
}
}
PrintWriter
PrintWriter is essentially a character-oriented version of PrintStream. It implements the
Appendable, Closeable, and Flushable interfaces. PrintWriter has several constructors.
The following have been supplied by PrintWriter from the start:
PrintWriter(OutputStream outputStream)
PrintWriter(OutputStream outputStream, boolean flushOnNewline)
PrintWriter(Writer outputStream)
PrintWriter(Writer outputStream, boolean flushOnNewline)
Here, outputStream specifies an open OutputStream that will receive output. The flushOnNewline
parameter controls whether the output buffer is automatically flushed every time println( ),
printf( ), or format( ) is called. If flushOnNewline is true, flushing automatically takes place. If
false, flushing is not automatic. Constructors that do not specify the flushOnNewline parameter
do not automatically flush.
The next set of constructors give you an easy way to construct a PrintWriter that writes its
output to a file.
PrintWriter(File outputFile) throws FileNotFoundException
PrintWriter(File outputFile, String charSet)
throws FileNotFoundException, UnsupportedEncodingException
PrintWriter(String outputFileName) throws FileNotFoundException
PrintWriter(String outputFileName, String charSet)
throws FileNotFoundException, UnsupportedEncodingException
Search WWH :
Custom Search
Previous Page
Java SE 6 Topic Index
Next Page
Java SE 6 Bookmarks
Home