Java Reference
In-Depth Information
dt . detab ( new
new BufferedReader ( new
new InputStreamReader ( System . in )),
new
new PrintWriter ( System . out ));
}
public
public DeTab ( int
int n ) {
ts = new
new Tabs ( n );
}
public
public DeTab () {
ts = new
new Tabs ();
}
/** detab one file (replace tabs with spaces)
* @param is - the file to be processed
* @param out - the updated file
*/
public
public void
void detab ( BufferedReader is , PrintWriter out ) throws
throws IOException {
String line ;
while
while (( line = is . readLine ()) != null
null ) {
out . println ( detabLine ( line ));
}
}
/** detab one line (replace tabs with spaces)
* @param line - the line to be processed
* @return the updated line
*/
public
public String detabLine ( String line ) {
char
char c ;
int
int col ;
StringBuffer sb = new
new StringBuffer ();
col = 0 ;
for
for ( int
int i = 0 ; i < line . length (); i ++) {
// Either ordinary character or tab.
iif (( c = line . charAt ( i )) != '\t' ) {
sb . append ( c ); // Ordinary
++ col ;
continue
continue ;
}
ddo { // Tab, expand it, must put >=1 space
sb . append ( ' ' );
} while
while (! ts . isTabStop (++ col ));
}
return
return sb . toString ();
}
}
Search WWH ::




Custom Search