473,387 Members | 3,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Using System.setIn to Change the InputStream

Hi All

I am trying to change my System.in InputStream to instead take values from the terminal window but take values from a JEditorPane or JTextBox.

I have this to add the text to the new InputStream which has been declared.
Expand|Select|Wrap|Line Numbers
  1. GUI Class:
  2. public static InputStream consoleInputStream;
  3. ...
  4. sendButton.addActionListener(new ActionListener() {
  5.     public void actionPerformed(ActionEvent e) {
  6.         String message = sendPane.getText();
  7.         consoleInputStream = new ByteArrayInputStream(message.getBytes());
  8.         sendPane.setText("");
  9.     }
  10. });
  11.  
I then want to use this in another class to output the text:
Expand|Select|Wrap|Line Numbers
  1. System.setIn(GUI.consoleInputStream);
  2. ...
  3. public static String readLine() {
  4.     String s = null;
  5.     BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
  6.     try {
  7.         s = in.readLine();
  8.     } catch (IOException e) {
  9.         e.printStackTrace();
  10.     }
  11.     return s;
  12. }
  13.  
But I get java.lang.NullPointerException at java.io.Reader. (Unknown Source) at java.io.InputStreamReader. (Unknown Source).

What I have is a CLI applciation that runs off the User inputs from the terminal within Eclipse all I want to do is change main System.in input Stream to a Jtextbox output. I have the above working just in CLI (of course not setting System.setIn()...)

Any pointers would be awsome!
Jan 13 '11 #1
0 1515

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: Andre | last post by:
I have two questions; 1) When executing the sub routine "TestStructure", I'm trying to update the member "intTyres" in the structure "structureCar" dynamically using System.Reflection. The code...
10
by: Fabrizio | last post by:
(Sorry for the crosspost, but I really don't know which is the right newsgroup!) Hi all, I try to change the password to a user that as to change the password at first logon: try {
1
by: melanieab | last post by:
Hi again, I'm trying to programatically sort a datagrid. I did find the following code, and it does work, but, when a column header is clicked, the data only sorts in descending order. Clicking...
4
by: marcelino | last post by:
Hi, I have c# express beta I try to write the following using clause: System.Runtime.Remoting.Channels.Http; because I want to create a http channel. HttpChannel aJobChannel = new...
2
by: Ryan | last post by:
Hi, I receive an access denied error (see below) when attempting to send an email with BodyFormat=MailFormat.Html from an asp.net page. Exactly the same code works fine in a console...
9
by: garyusenet | last post by:
I am using a C# solution that somebody kindly sent me. It was a console application. I am trying to get use of the MessageBox. I have added the following using directive to the namespaces at...
3
by: José Joye | last post by:
In my application (written for Compact Framework 2.0 ), I have to be informed whenever a system Time change occurs (NTP, daylight saving, ...). Under the normal framework, I'm able to use the...
2
by: Mike | last post by:
I know, it is old question. Is there some new way to protect system time changes with C# 2.0? What is the best way based on your oppinion? Thanks, I appreciate your help. Mike
11
by: Ed Bitzer | last post by:
I have been able using the namespace System.Web.Mail and its method Smtp.mail.send to mail simple text messages to a small group within our 55 and older community. I need help expanding the...
6
by: Chocolade | last post by:
Hi, Im using System.Net.Mail to send email in my application it was working great without any problems untill this morning after like 20-30 tries it was sending the email ok then suddenly this...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.