Members Login.
 

Please register HERE to be part of our Community
Contest of the Day.
 
Participate and Earn $$$.
Looking to Hire.
 
Earn By Posting
 
Participate in forum and Earn $$$.
  • Referrer Credit - BRL$ 100
  • Positive Rep Cr. - BRL$ 3
  • New Thread Cr.- BRL$ 3
  • Posting Cr. - BRL$ 3
  • Post size Credit
Full List of BRL$ Earnings
Sponsors.
 


Java Coding / Development discussions related to JAVA PROGRAMMING

Reply
  #1 (permalink)  
Old 03-18-2008
Peon
 
Join Date: Mar 2008
Posts: 7
Rep Power: 0
techno is on a distinguished road
BRL$: 129.32
Default How to read text file?

I am trying to read a text file using java, Can anyone point to a link from where I can get information about it?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 03-18-2008
Link Exchange - Jr. Member
 
Join Date: Mar 2008
Posts: 264
Rep Power: 5
mira is on a distinguished road
BRL$: 7.42
Default Re: How to read text file?

You can read text file using java here is a code

HTML Code:
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class FileInput {

  public static void main(String[] args) {

    File file = new File("C:\\a.txt");
    FileInputStream fis = null;
    BufferedInputStream bis = null;
    DataInputStream dis = null;

    try {
      fis = new FileInputStream(file);

      bis = new BufferedInputStream(fis);
      dis = new DataInputStream(bis);

      while (dis.available() != 0) {

        System.out.println(dis.readLine());
      }

      fis.close();
      bis.close();
      dis.close();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 2 Weeks Ago
Link Exchange - Jr. Member
 
Join Date: Apr 2008
Posts: 100
Rep Power: 3
webvigor is on a distinguished road
BRL$: 225.09
Default Re: How to read text file?

You can do so by Input-output streams. Code which is listed above to me is pretty much self explanatory. You will have to open the buffer then read or write the file and then will has to close that buffer stream.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Writing in text File Using c# mira C / C++ / C # 0 03-15-2008 10:30 AM
Include the data from a text file Rss_Feeds PHP 0 09-30-2007 01:16 AM
Display results from text file in multiple pages Rss_Feeds PHP 0 09-14-2007 12:21 PM
Multidimensional array from text file Rss_Feeds PHP 0 09-05-2007 09:56 AM
How to Change the Text Field of a Remote File? brl_admin JavaScript 0 09-04-2007 09:50 AM


 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91