Results 1 to 3 of 3
  1. #1
    CuppaJava is offline Member
    Join Date
    Aug 2014
    Posts
    3
    Rep Power
    0

    Default How to manually put data into an InputStream?

    Hi all, I am new to programming in regards to I/O, channels, SSH, etc... and I'm finding it quite difficult to find a solution to my problem.
    At the moment I am trying to transform the Shell.java program from the JCraft JSch examples; JSch - Java Secure Channel - Examples

    The way in which I am trying to transform it is by instead of having the character input go into the channel automatically from the keyboard (refer to line 77 in Shell.java), I just want to pro-grammatically insert characters in to the channel at my discretion, so for example I have a string called unixCommand that I want to insert into the channel, and I don't want there to be any other way of inserting into the channel such as the standard input stream, so for example I'd have the statement <insert unixCommand to UNIX box at other side of channel> inserted somewhere after line 100 in Shell.java.

    I was thinking that maybe I have to use some other InputStream object at line 77 when setting the channels input stream instead of System.in, but I am not sure how to do this (but really I'm not sure if I'm even on the right tracks?). I believe all this confusion may be down to a misunderstanding with the general concepts involved with channels and I/O and if so would be very grateful if anyone could help rectify this misunderstanding of mine.
    Last edited by CuppaJava; 08-23-2014 at 11:02 PM.

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,023
    Rep Power
    6

    Default Re: How to manually put data into an InputStream?

    Perhaps PipedInputStream and PipedOutputStream would help. They are
    documented in the Java API.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    CuppaJava is offline Member
    Join Date
    Aug 2014
    Posts
    3
    Rep Power
    0

    Default Re: How to manually put data into an InputStream?

    Quote Originally Posted by jim829 View Post
    Perhaps PipedInputStream and PipedOutputStream would help. They are
    documented in the Java API.

    Regards,
    Jim
    Thanks for the quick reply, I'll check this out when I'm back at work on Monday and see if I can hack it.

Similar Threads

  1. I need to manually terminate my threads.
    By coolman50544 in forum New To Java
    Replies: 7
    Last Post: 07-28-2014, 04:24 AM
  2. manually trigger tooltips
    By stringargs in forum AWT / Swing
    Replies: 1
    Last Post: 05-04-2011, 09:51 PM
  3. Manually install Tomcat 7.02
    By contributor in forum New To Java
    Replies: 4
    Last Post: 09-04-2010, 03:27 PM
  4. Manually adding a component
    By djc in forum NetBeans
    Replies: 3
    Last Post: 04-01-2009, 12:51 PM
  5. Unable to read data from inputstream
    By renuka_anil in forum Java Servlet
    Replies: 0
    Last Post: 01-29-2009, 04:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •