[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Java I/O on Stream
May be the attached snap shot will help you !!!!
public String sckReceiveRead()
{
BufferedReader sckSendIn = null;
StringBuffer result = new StringBuffer(10000);
if(connectionFlag)
{
try
{
//SckReceive is declared as Socket
instance
sckSendIn = new BufferedReader(new
InputStreamReader(sckReceive.getInputStream()));
int offset=0;
while(sckSendIn.ready())
{
while((offset = sckSendIn.read()) !=3)
{
if( offset == -1 ) break;
if(offset == 0)
{
offset = 32;
}
result.append((char)offset);
}
result.append("\u0003");
}
sckSendIn = null;
}
catch(IOException ex)
{
connectionFlag = false;
// System.out.println("Exception in assigning
value");
// ex.printStackTrace();
}
}
return result.toString();
}
--- Vikrant.Verma@alltel.com wrote:
> U can write the readline() function but why reinvent
> the wheel. The
> bufferedreader does this for you. Also
> bufferedreader is a subclass of
> reader so u can read a byte, array of bytes and a
> line.
>
> I have not been able to grasp this thread
> completely, so if this does
> not help then detail your scenario a bit more
> clearly.
> -Vikrant
>
> -----Original Message-----
> From: cfowler [mailto:cfowler@outpostsentinel.com]
> Sent: Thursday, November 07, 2002 2:56 PM
> To: Brian Lee
> Cc: ajug-members@ajug.org
> Subject: Re: Java I/O on Stream
>
>
> I'm working on a socket where I have to start in
> line mode to validate
> commands then drop toy char by char mode for user
> interaction. I was
> not buffering until we ran this class on a 800 mhz
> machine. Things
> started falling apart because I was not able to read
> data fast enough
> from the socket and read() was not returning a line.
> Then I relized
> that I needed to do a readLine() instead and then
> drop to non-buffered
> mode.
>
>
>
> On Thu, 2002-11-07 at 14:40, Brian Lee wrote:
> > If it's character data you can use
> >
>
java.io.BufferedReader(java.io.InputStreamReader(InputStream)).
> >
> > It will also buffer your stream for performance
> purposes.
> >
> > I'm not a big fan of java io, but I keep telling
> myself that the new
> jdk1.4
> > nio is going to be better (but can't bring myself
> to look at it).
> >
> > BAL
> >
> > >From: cfowler <cfowler@outpostsentinel.com>
> > >To: ajug-members@ajug.org
> > >Subject: Java I/O on Stream
> > >Date: 07 Nov 2002 14:30:23 -0500
> > >
> > >
> > >
> > >Java I/O still confuses me!. I need to take an
> InputStream that is
> > >connected to a socket and convert it to a Object
> that will allow me
> to
> > >do a readLine(). I gues I can allways extend
> InputStream and add a
> > >readLine() function.
> > >
> > >Any help would be appreciated.
> > >
> > >Chris
> >
> >
> >
>
_________________________________________________________________
> > The new MSN 8: smart spam protection and 2 months
> FREE*
> > http://join.msn.com/?page=features/junkmail
> >
> >
> >
>
>
=====
Amardeep Singh Talwar678 642 8898 (C)
__________________________________________________
Do you Yahoo!?
U2 on LAUNCH - Exclusive greatest hits videos
http://launch.yahoo.com/u2