There's a method readLine in BufferedReader which you can use to read the contents.
In the example you have provided you are reading the content but the content has been assigned to some variable on once i.e before the loop. But in the loop there's readLine but the returned value is not assigned to any variable. So the change would be to assign the value of readLine to some variable.
Because you're doing it incorrectly. Most importantly, available() doesn't do what you think it does. Also, you only once assign anything to c. Finally, you have two different InputStream wrappers around ob. You really shouldn't do that. Either drop bis completely, or put it between ob and ds:
As for the reading, the technique I prefer is the following:
Now there is one more thing I'd like to improve. You're using DataInputStream for reading a text file. DataInputStream is actually meant for binary data. For text files, use Readers:
i m getting this Error if i m running this:
Exception in thread "main" java.lang.NullPointerException at java.io.FilterInputStream.available(FilterInputStream.java:159)
Anyone please help....
Also, note that it's generally bad practice to catch RuntimeException, Error, or any of their descendants (such as NullPointerException). A RuntimeException indicates a bug in your code, and you generally can't (and shouldn't) recover from it. Best to let the program just die at that point.
And you should be aware that just printing out the exception is not actually proper handling. The problem occurred, and catching the exception doesn't magically fix that. If all you do is print it out, but you don't actually fix it or rethrow it or another exception, then your program has no way of knowing that anything went wrong, and it just continues along thinking eveyrthing is okay when it's not. (For simply academic exercises, just printing the stack trace can be sufficient, but for production code, if you're doing to catch and not rethrow, then you have to actually fix the problem.
When you create dis, bis is still null. Swap these two initialization lines. Then go ahead and read my previous post again, because you've obviously ignored everything I said in it. You're still using available() which you really, really, really shouldn't do. And you really should use FileReader and BufferedReader instead of FileInputStream, BufferedInputStream and DataInputStream as I had also previously suggested.