HighTechTalks DotNet Forums  

BufferedReader.readLine() returns null

Dotnet VJSharp microsoft.public.dotnet.vjsharp


Discuss BufferedReader.readLine() returns null in the Dotnet VJSharp forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
asilter
 
Posts: n/a

Default BufferedReader.readLine() returns null - 04-07-2005 , 08:01 AM






i've added a watch to reader.readline() and alinanMesaj name. i am debugging
my codes with stepinto option. after below line;
reader=new BufferedReader(new InputStreamReader(client.getInputStream()));
i see the the value of reader.readLine() watch correctly. below line is the
line right after above line.
alinanMesaj=reader.readLine();
when i execute this with stepinto i see
alinanMesaj watch is "null", and
readerReadLine() watch is
"function 'reader.readLine()' evaluated and returned null"

why, please help!

Reply With Quote
  #2  
Old   
asilter
 
Posts: n/a

Default Re: BufferedReader.readLine() returns null - 04-08-2005 , 02:31 PM






that is a String type of data and i know that BufferedReader.readLine()
returns String. My code is below:

package ChatVisual2Client;

import System.Drawing.*;
import System.Collections.*;
import System.ComponentModel.*;
import System.Windows.Forms.*;
import System.Data.*;

import java.io.*;
import java.net.*;

/**
* Summary description for Form1.
*/
public class Form1 extends System.Windows.Forms.Form
{
private System.Windows.Forms.GroupBox groupBox1;
private static System.Windows.Forms.TextBox txtMessage;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.Label label1;
private static System.Windows.Forms.TextBox txtConnection;


/**
* Required designer variable.
*/
private System.ComponentModel.Container components = null;

public Form1()
{
InitializeComponent();

try
{
Socket client=new Socket("192.168.0.139",15);
txtConnection.set_Text("Kuruldu!");
BufferedReader reader=new BufferedReader(new
InputStreamReader(client.getInputStream()));
String alinanMesaj=reader.readLine();
if(alinanMesaj!=null)
{
txtMessage.set_Text(reader.readLine());
}
}
catch (IOException ioe)
{
System.err.println ("Error " + ioe);
}
}
protected void Dispose(boolean disposing)
{
if (disposing)
{
if (components != null)
{
components.Dispose();
}
}
super.Dispose(disposing);
}

#region Windows Form Designer generated code
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.txtMessage = new System.Windows.Forms.TextBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.txtConnection = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.set_Location(new System.Drawing.Point(16, 64));
this.groupBox1.set_Name("groupBox1");
this.groupBox1.set_Size(new System.Drawing.Size(312, 200));
this.groupBox1.set_TabIndex(3);
this.groupBox1.set_TabStop(false);
this.groupBox1.set_Text("Mesaj");
//
// txtMessage
//
this.txtMessage.set_Location(new System.Drawing.Point(24, 88));
this.txtMessage.set_Multiline(true);
this.txtMessage.set_Name("txtMessage");
this.txtMessage.set_Size(new System.Drawing.Size(296, 168));
this.txtMessage.set_TabIndex(4);
this.txtMessage.set_Text("");
//
// groupBox2
//
this.groupBox2.get_Controls().Add(this.label1);
this.groupBox2.get_Controls().Add(this.txtConnecti on);
this.groupBox2.set_Location(new System.Drawing.Point(16, 8));
this.groupBox2.set_Name("groupBox2");
this.groupBox2.set_Size(new System.Drawing.Size(184, 48));
this.groupBox2.set_TabIndex(5);
this.groupBox2.set_TabStop(false);
this.groupBox2.set_Text("Baglanti");
//
// txtConnection
//
this.txtConnection.set_Location(new System.Drawing.Point(72, 16));
this.txtConnection.set_Name("txtConnection");
this.txtConnection.set_TabIndex(3);
this.txtConnection.set_Text("");
//
// label1
//
this.label1.set_Font(new System.Drawing.Font("Microsoft Sans Serif",
8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point,
((ubyte)(System.Byte)(((ubyte)162)))));
this.label1.set_Location(new System.Drawing.Point(16, 19));
this.label1.set_Name("label1");
this.label1.set_Size(new System.Drawing.Size(56, 16));
this.label1.set_TabIndex(4);
this.label1.set_Text("Durum :");
//
// Form1
//
this.set_AutoScaleBaseSize(new System.Drawing.Size(5, 13));
this.set_ClientSize(new System.Drawing.Size(336, 278));
this.get_Controls().Add(this.groupBox2);
this.get_Controls().Add(this.txtMessage);
this.get_Controls().Add(this.groupBox1);
this.set_Name("Form1");
this.set_Text("Sohbet Programı - Client");
this.groupBox2.ResumeLayout(false);
this.ResumeLayout(false);

}
#endregion
public static void main(String[] args)
{
Application.Run(new Form1());
}
}

"Lars-Inge Tønnessen [VJ# MVP]" wrote:

Quote:
Hi Asilter

Please show us more code. I can read code better than text.

What is "alinanMesaj" ?

Maybe this is a textfield you forget to make a new instance of and assigning
the value to the alinanMesaj.Text filed ? I'm only guessing because I don't
know what "alinanMesaj" is from your very short code sample.


reader=new BufferedReader(new InputStreamReader(client.getInputStream()));
alinanMesaj=reader.readLine();


Best regards,
Lars-Inge Tønnessen





Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.