All Downloads are FREE. Search and download functionalities are using the official Maven repository.

edu.uiuc.ncsa.sas.StringIO Maven / Gradle / Ivy

There is a newer version: 5.4.3
Show newest version
package edu.uiuc.ncsa.sas;

import edu.uiuc.ncsa.security.util.cli.IOInterface;

import java.io.IOException;

/**
 * An IO class backed by strings. This is used in e.g. web apps as a dummy where the
 * actual control flow is managed by something else. Call {@link #flush()} between
 * calls to reset everything.
 * 

Created by Jeff Gaynor
* on 8/15/22 at 2:14 PM */ public class StringIO implements IOInterface { public StringIO(String input) { this.input = input; } public String getInput() { return input; } public void setInput(String input) { this.input = input; } String input; public StringBuilder getOutput() { return output; } public void setOutput(StringBuilder output) { this.output = output; } StringBuilder output = new StringBuilder(); @Override public String readline(String prompt) throws IOException { return input; } @Override public String readline() throws IOException { return input; } @Override public void print(Object x) { output.append(x); } @Override public void println(Object x) { output.append(x + "\n"); } @Override public void flush() { input = ""; output = new StringBuilder(); } @Override public void clearQueue() { } @Override public boolean isQueueEmpty() { return false; } @Override public void setBufferingOn(boolean bufferOn) { } @Override public boolean isBufferingOn() { return false; } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy