package commands; import java.io.IOException; import java.io.PipedOutputStream; import kernel.AbstractProcess; import kernel.AppException; /** * Prints the current directory. * * @author Václav Podlena */ public class pwd extends AbstractProcess { public void realization() throws AppException { PipedOutputStream output = (this.getOut() != null) ? (PipedOutputStream) this .getOut() : null; try { String s = new String(getParentCurrentPath() + "\n"); output.write(s.getBytes()); output.flush(); } catch (IOException ioe) { ioe.printStackTrace(); throw new AppException("Chyba I/O\n" + ioe.getMessage(), ioe); } catch (NullPointerException npe) { npe.printStackTrace(); throw new AppException("Output není definován\n" + npe.getMessage(), npe); } catch (Exception e) { e.printStackTrace(); throw new AppException("Neznámá Chyba.\n" + e.getMessage(), e); } } /** * Provides help for users. * */ public String getHelp() { return "\n\nDescription:\nPrints the current directory.\n\n"; } }