aspose file tools*
The moose likes Java in General and the fly likes Input/Output Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Input/Output Problem " Watch "Input/Output Problem " New topic
Author

Input/Output Problem

Siddharth Bhargava
Ranch Hand

Joined: Feb 23, 2007
Posts: 268
I have written a program to get the input from a file using DataInputStream and display it on console. The Program is as follows:


The problem that is coming is the output on the console is not human readable. Please tell where i am going wrong.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42919
    
  68
DataInputStream is not meant for reading clear text (which is what you're doing, judging from the filename). Leave it out and use the BufferedInputStream directly, or -even better- wrap it in a BufferedReader that allows you to read line by line.
bart zagers
Ranch Hand

Joined: Feb 05, 2003
Posts: 234
This type of small snippets, you can easily find on the Java Developers Almanac.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
If it really is a .txt file, have you tried java.util.Scanner?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Input/Output Problem