java I/O


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 13 of 13

Thread: java I/O

  1. #1
    Join Date
    Nov 2003
    Posts
    13

    java I/O

    hi all,

    i am having trouble understanding how java's input output system works, as the sun's tutorial is helpful with swing stuff its is extramly vague with I/O.

    and yes i have many books on java yet all fail to describe java's I/O effectively for the noob :P

    has any one a clue on a any good books or resoures's on the internt which deal with I/O as i would like to figure it out my self with out u peopole doing my work for me because i cant get a job with other people doing my work.

    im basicly coding a simple note pad application yet dont know y you need to

    "throws IOException" ect

    so please, if any one know of any good resources with examples i would be thankful
    Attached Files Attached Files

  2. #2
    Join Date
    Nov 2003
    Posts
    13
    so yes i am obioulsly refering to Files, FileReader, FileWriter ect

    NOT the obvious console I/O System.out.print
    or
    System.in.read

  3. #3
    Join Date
    May 2004
    Posts
    219
    It's pretty easy stuff if you just read through the API a bit and test some stuff out. All you really need is a BufferedReader/BufferedWriter.

    IOExceptions are necessary because there are many different things that can go wrong while trying to use a stream. For instance, you may try to create a FileReader with a file that does not exist, so an IOException will be thrown.

  4. #4
    Join Date
    Feb 2004
    Posts
    541
    you don't need to declare your method to throw IOExceptions, you can catch them if you want. They have to be caught somewhere after all.

  5. #5
    Join Date
    Nov 2003
    Posts
    13
    ok cool it makes sence that a exception has to be throwen like u stated, but as i said sun's tutorial is very vage as to how to correctly use (code) I/O and the jave api is obviously daughting for a noob such as myself.

    so do u know of any good resources which teach the use of I/O with or without working examples ?????

  6. #6
    Join Date
    May 2004
    Posts
    219

  7. #7
    Join Date
    Nov 2003
    Posts
    13
    as the sun's tutorial is helpful with swing stuff its is extramly vague with I/O.
    i posted that twice,

    jesus christ didnt u read my posts,

    no offence but i said it not once but twice. *sigh*

  8. #8
    Join Date
    May 2004
    Posts
    219
    First of all, I suggested reading the API at first, not the tutorials. Second, there is no need to get pissy. If you can't read an API/tutorial (oh by the way, have you heard of search engines?) enough to learn what should be a very basic concept for someone wanting to use file I/O, then maybe you need to spend more time learning the language and less time demanding exactly what you said you didn't want:
    i would like to figure it out my self with out u peopole doing my work for me because i cant get a job with other people doing my work.

  9. #9
    Join Date
    Feb 2004
    Posts
    541
    exactly which tutorial didn't make sense? I haven't found many that didn't help me at least a little bit.

  10. #10
    Join Date
    Nov 2003
    Posts
    13
    drain this is the New to Java section
    try to remember that next time.

    you obviously understand java, but maby your english needs a little attention

    mike: yeah i get what u mean but i just need that extra bit of background. so if you have any books or documents u can recommend for the New to Java sort of person that would be good.

    thanks any way

  11. #11
    Join Date
    Feb 2004
    Posts
    541
    The only java book i've ever read is Introduction to Java Programming by Liang, but I have no idea how this compares to other java books. It was just the recommended book on my course. To be honest if I ever don't know how to use something i've always used the sun API and tutorials. The API lists all the methods for a particular class and explains what they do. This is usually enough to know how to use a class, but they sometimes stick the tutorial in if its more complex.

  12. #12
    Join Date
    May 2004
    Posts
    219
    I will now quote the API.


    BufferedReader in
    = new BufferedReader(new FileReader("foo.in"));

    will buffer the input from the specified file. Without buffering, each invocation of read() or readLine() could cause bytes to be read from the file, converted into characters, and then returned, which can be very inefficient.


    BufferedReader(Reader in)
    Create a buffering character-input stream that uses a default-sized input buffer.
    String readLine()
    Read a line of text.
    Code:
    java.io 
    Class FileReader
    
    java.lang.Object
      java.io.Reader
          java.io.InputStreamReader
              java.io.FileReader
    FileReader(String fileName)
    Creates a new FileReader, given the name of the file to read from.

  13. #13
    Join Date
    Nov 2003
    Posts
    13
    ill check out that book and see how i go

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center