nullpointer exception

Can anyone help? when I run the code below, I end up with a

NullPointerException. I figured is because I am trying to do

outputstream.write(cmdstring.getBytes()); on line 46.

I need help figuring out why it gives me an exception. Thanks

Drake01

import java.util.*;

import javax.comm.*;

import java.io.*;

import java.awt.Toolkit;

publicclass Wavetronix

{

static CommPortIdentifier portID;

static Enumeration portlist;

static SerialPort serialport;

static OutputStream outputstream;

static String cmdstring ="Hello World";

publicstaticvoid main(String args[])

{

portlist = portID.getPortIdentifiers();

while (portlist.hasMoreElements())

{

portID = (CommPortIdentifier) portlist.nextElement();

if (portID.getPortType() == CommPortIdentifier.PORT_SERIAL)

{

System.out.println(portID.getName());

if(portID.getName().equals("COM1"))

{

try

{

serialport = (SerialPort) portID.open("WavetronixApp", 2000);

System.out.println("did portID.open return null?" + (serialport ==null));

}catch(PortInUseException e){}

try

{

serialport.setSerialPortParams(9600,

SerialPort.DATABITS_8,

SerialPort.STOPBITS_1,

SerialPort.PARITY_NONE);

}catch (UnsupportedCommOperationException e){}

try

{

outputstream.write(cmdstring.getBytes());

}catch (IOException e){System.out.println("unsuccessful write");}

}

}

}

}

}

[3079 byte] By [drake01a] at [2007-10-2 0:21:09]
# 1
I don't see how that line can throw an NPE.Post the actual error information, and identify the line that's listed.
ChuckBinga at 2007-7-15 16:22:38 > top of Java-index,Developer Tools,Java Compiler...
# 2

Your question was previously answered in one of your many and repeated duplicate postings.

Don't duplicate your posts, all it does is waste your time and mine, and irritate the h-ll out of anyone who finds that the question was previously answered.

Keep doing it and you'll find no one will reply, as well. . .

ChuckBinga at 2007-7-15 16:22:38 > top of Java-index,Developer Tools,Java Compiler...