All pastes #35766 Raw Edit

Anonymous

public text v1 · immutable
#35766 ·published 2006-01-04 22:38 UTC
rendered paste body
import java.io.*;

public class compress {

	public void doCompress (Reader in, Writer out) throws IOException {
		
		boolean skipNextSpace = false;
		int charRead;
		
		while ((charRead = in.read()) != -1) {
			
			boolean isSpace = (char)charRead == " ".toCharArray()[0];
			
			if (!skipNextSpace && isSpace) {
				out.write(charRead);
			}
			
			skipNextSpace = isSpace;
		}
		
		in.close();
	}
	
}