Page 2 of 4 FirstFirst 1234 LastLast
Results 21 to 40 of 63
Like Tree3Likes

Thread: FileInputStream question.

  1. #21
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,448
    Rep Power
    25

    Default Re: FileInputStream question.

    Why are you reading the file? Do you want to see its contents?
    Where should read() put the data it reads?

  2. #22
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: FileInputStream question.

    Norm,

    There is nothing specific I want to do except learning JAVA.
    Why are you answering my questions with questions?

    As I was going through the API,

    I have seen this method,
    and my question is:


    Why would I create an array and put it into read method as an argument which belongs to a FileInputStreamer object that is referencing to a file ?
    and Fuburable's answer, altough not very clear to my as I am a beginner, has at least shown me a way.

    Thank you for sparing your time, and trying to help.

  3. #23
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,529
    Blog Entries
    7
    Rep Power
    20

    Default Re: FileInputStream question.

    If you want an InputStream that reads from a byte array (not a file), have a look at the ByteArrayInputStream class. (it is also mentioned in the API documentation as a sub class of the InputStream class).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #24
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,448
    Rep Power
    25

    Default Re: FileInputStream question.

    My questions are to make you think. What is your answer to the last question?

  5. #25
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: FileInputStream question.

    Why are you reading the file? Do you want to see its contents?
    Where should read() put the data it reads?
    I am not reading anyfile.. I do not want to see its contents.
    If I were reading it, I guess it would have put it in an byte array.

    What is your answer to my question?:

    Why would I create an array and put it into read method as an argument which belongs to a FileInputStreamer object that is referencing to a file ?

    or I can put it this way:

    Why would I ever use this method:
    public int read(byte[] b)
    that is found in a FileInputStream class ?

  6. #26
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,448
    Rep Power
    25

    Default Re: FileInputStream question.

    Why would I ever use this method:
    To read bytes from a file.

  7. #27
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: FileInputStream question.

    Quote Originally Posted by Norm View Post
    To read bytes from a file.
    This method does not serve that purpose.

  8. #28
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,448
    Rep Power
    25

    Default Re: FileInputStream question.

    Are you telling me how the read method works?
    What is the purpose of the read() method?

  9. #29
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: FileInputStream question.

    not the read() method,

    public int read(byte[] b) method..

  10. #30
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,448
    Rep Power
    25

    Default Re: FileInputStream question.

    read(byte[] b)
    That is the method I'm talking about. The one you mentioned in post#25 and I answered in post #26

  11. #31
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: FileInputStream question.

    Quote Originally Posted by Norm View Post
    That is the method I'm talking about.
    Can you give an example then ? Maybe a few lines of code ?
    How would you read bytes from a file using this method ? ( with the byte[] b argument )

  12. #32
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,448
    Rep Power
    25

    Default Re: FileInputStream question.

    There must be some examples here. Use Search to find them.
    Or use Google.

    Better yet, write you own code to read a few bytes into an array and use the Arrays class's toString() method to format that array for printing in a println statement.

  13. #33
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: FileInputStream question.

    There is an answer to everything somewhere in the world.
    No one should ask questions to anyone then.. ( Except it is something personal to a specific person.. Like where his wallet is or what his plans are.. )

    And if you weren't going to help at the first time, why bother ?

  14. #34
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,448
    Rep Power
    25

    Default Re: FileInputStream question.

    You are going to have a hard time finding people to help you.
    Fubarable likes this.

  15. #35
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: FileInputStream question.

    It would have been so much easier if you could have provided a few lines of code.

    Obviously I am struggling here, defining myself and understanding this method.

    Anyway, difficult is done at once, impossible takes time..

    I will find people to help me, believing is everything.. :)

    Thanks for your efforts.

  16. #36
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,448
    Rep Power
    25

    Default Re: FileInputStream question.

    I'm surprised that Search or Google did not return samples.

  17. #37
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: FileInputStream question.

    I did not try.

    I really like personal connection.

    I will just wait until I make some friends who knows JAVA.

  18. #38
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: FileInputStream question.

    Quote Originally Posted by fatabass View Post
    I did not try.

    I really like personal connection.
    I will just wait until I make some friends who knows JAVA.
    Here's some lines of code. Hope it helps.

    Java Code:
    public static void main(String[] args) {
    
       doNotHelpList.add(fatabass);
    
       if (fatabass.senseOfEntitlement() <= REALISTIC_EXPECTATIONS) {
          doNotHelpList.remove(fatabass);
       }
    }
    Last edited by Fubarable; 01-14-2012 at 08:14 PM.

  19. #39
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,448
    Rep Power
    25

    Default Re: FileInputStream question.

    There's a saying in sports training: No pain, no gain.
    The more effort you put into something the better you will get.

  20. #40
    fatabass is offline Senior Member
    Join Date
    Nov 2011
    Location
    Turkey
    Posts
    380
    Blog Entries
    24
    Rep Power
    3

    Default Re: FileInputStream question.

    There are many sayings:

    In about the same degree as you are helpful, you will be happy. ~Karl Reiland
    Happiness comes when your work and words are of benefit to yourself and others. ~Buddha

Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. FileInputStream
    By lakpathy in forum New To Java
    Replies: 2
    Last Post: 01-18-2011, 11:32 AM
  2. FileInputStream
    By lakpathy in forum New To Java
    Replies: 4
    Last Post: 01-17-2011, 12:00 PM
  3. FileInputStream Problems.
    By bayan in forum New To Java
    Replies: 18
    Last Post: 08-11-2010, 11:11 AM
  4. FileInputStream
    By pachufir in forum New To Java
    Replies: 3
    Last Post: 12-11-2009, 05:07 PM
  5. FileOutputStream > int > FileInputStream
    By dudejonne in forum New To Java
    Replies: 11
    Last Post: 11-11-2009, 04:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •