I try to read a file and display the data on the TextField.
But it does not read the next line.
For example, for two lines,

How are you? Long time no see.
I remember you.

The program does not show the sentence "I remember you"
How should i do that?

try {
			
			
			fileconnection=(FileConnection)Connector.open(path+filedir);
			InputStream is=fileconnection.openInputStream();
			ByteArrayOutputStream baos=new ByteArrayOutputStream();
			byte[]buffer=new byte[1024];
			int bytesRead=0;
			while((bytesRead=is.read(buffer))!=-1)
			{
				baos.write(buffer,0,bytesRead);
				TFileReadWriteMIDlet.tfilereadwritemidlet.mainform.txtfield.setString(baos.toString());
			}
			
			//TFileReadWriteMIDlet.tfilereadwritemidlet.mainform.txtfield.setString(baos.toString());
		
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

Are you sure that you actually reading second line? Did you check it?

yes. The program reads the second line " Long time no see"
The program reads until the next line.
How should I do that?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.