サンプル.java
class Sample
{
private BufferedOutputStream output;
public handleRequest(Socket socket)
{
this.output = new BufferedOutputStream(socket.getOutputStream(), BUFFSIZE);
sendString("sometext");//This is working fine
}
public void sendString(String str) throws IOException
{
ByteArrayOutputStream bytestream;
bytestream = new ByteArrayOutputStream(str.length());
DataOutputStream out;
out = new DataOutputStream(bytestream);
for (int i = 0; i < str.length(); i++)
out.write((byte) str.charAt(i));
output.write(bytestream.toByteArray(), 0, bytestream.size());
output.flush();
}
}
AnotherClass.java
class AnotherClass
{
public send()
{
Sample smp = new Sample();
smp.sendString("somestring");//This is not working
}
}
AnotherClass.javaでsendstringメソッドを呼び出すたびに、NullPointerExcetpiton.Iamがわかりません.誰か助けてください..よろしくお願いします....