About abstract method read() in class InputStream

I would like to know if behind the method
public abstract int read() throws IOException
in the abstract class InputStream there is some code that
is called when I have to read a stream. In this case where can I find
something about this code and, if is written in other languages, why
is not present the key word native?
Thanks for yours answers and sorry for my bad english.

Ciao Matteo.
Scusa se ti rispondo in ritardo... ma ero in pausa pranzo.
Chiedimi pure qualcosa di pi? specifico e se posso darti una mano ti rispondo.
Le classi astratte sono utilizzate per fornire un comportamento standard lasciando per? uno o pi? metodi non implementati... liberi per le necessit? implementative degli utilizzatori.
Nel caso specifico la classe InputStream ? una classe astratta che lascia non implementato il metodo read(). Tu nel tuo codice non utilizzerai mai questa classe come oggetto, ma nel caso specifico una sua sottoclasse che ha implementato il metodo read().
Se vai nelle api di InputStream vedrai che ci sono diverse sottoclassi che estendono InputStream. Guarda ad esempio il codice di ByteArrayInputStream: in questa classe il metodo read() non ? nativo ma restituisce un byte appartenente al suo array interno.
I metodi nativi (ad esempio il metodo read() della classe FileInputStream) non hanno implementazione java ma fanno invece riferimento a delle chiamate dirette al sistema operativo.
Per quanto riguarda la classe FilterInputStream di cui parlavi: essa nel suo costruttore riceve un InputStream. Questo significa che si deve passare nel costruttore non la classe InputStream (che ? astratta) ma una classe che la estende e che quindi non sia astratta. Il motivo per il quale FilterInputStream faccia riferimento a una classe di tipo InputStream al suo interno, ? che in java gli stream di input e di output possono essere composti l'uno sopra l'altro per formare una "catena" (a tal proposito vedi per maggiori dettagli uno dei tani articoli che si trovano in rete.... ad esempio ti indico questo http://java.sun.com/developer/technicalArticles/Streams/ProgIOStreams/). Comunque per dirla in due parole: tu puoi voler usare un FileInputStream per leggere un file, ma se hai bisogno di effettuare una lettura pi? efficiente (quindi bufferizzata) puoi aggiungere in catena al FileInputStream un oggetto di tipo FilterInputStream (nel caso specifico un BufferedInputStream che non ? altro che una sottoclasse di FilterInputStream).
Spero di aver chiarito qualche tuo dubbio!
Ciao
Diego

Similar Messages

  • About abstract method read() in class InputStream (third message)

    The subclass FilterInputStream is not abstract and extend InputStream: have you ever seen the implementation of that method in the source code available in SDK? It only calls that abstract method!!! I think it is not a very simple problem and anyway the answer is not in my diffrent books. Thanks for your non trivial answer.

    Please post this as a "reply" in your original thread
    http://forum.java.sun.com/thread.jspa?threadID=5192979&tstart=0
    Don't start a new thread, simply reply to one of the other posts in the original thread (there is a button "reply" on the right hand side).

  • About abstract method read() in class InputStream (second message)

    I know but my question needs other arguments. When the Java virtual machine must help me in reading some input stream, I imagine it uses some calls to the operating system: I would like to know if behind that method there is something which seems a system call even if is abstract and so without apparently code.

    Please post this as a "reply" in your original thread
    http://forum.java.sun.com/thread.jspa?threadID=5192979&tstart=0
    Don't start a new thread, simply reply to one of the other posts in the original thread (there is a button "reply" on the right hand side).

  • Misunderstanding about abstract methods

    I think my compiler just taught me something, and after reading the JLS I concluded that I had a misconception about abstract methods. However, if someone could confirm this I would feel more comfortable.
    I had defined a class structure like so:public abstract class Grandpa{
      public abstract void do();
    public abstract class Pa extends Grandpa {
      public void do(){
      // whatever
    public class Child extends Pa {
    }I got a compile error indicating that Child must implement do(). I had thought that since there was an implementation provided by Pa that Child didn't need to supply one, but I guess I was wrong. Right? :-)

    Nested where? Inside Pa? Other? Static?Inside Pa.
    It sounds like you're satisfied, but if you want to
    continue the discussion, I'll make the standard
    request. Come on, you know it, say it with me: Provide
    a small, complete, working (in that it doesn't
    compile) example that demonstrates this. :-)Yeah, that's exactly what I was working on for the bug report, but I can't get the compile error in my small example. Argh! I'll have to go back some time and build it up to match the other classes until I get the error, because I still get it consistently with the real thing. I have no idea what the key factor is, though - I've tried everything obvious and I don't have time to work through it right now.
    No prob. It's a pleasant break from arguing with UJ.
    :-)Glad I could offer you a distraction. :-) I'll post here again if I ever figure out what the deal is.

  • Which of the following are true about abstract methods in EJB 2.0

    Hi guys I'm beginner to EJB and i got some unanswered questions.
    Can any one of you please.. give answers?
    Thanks if you do...
    Which of the following are true about abstract methods in EJB 2.0
    CMP?
    Choose all correct answers:
    1. Abstract accessor methods should not be exposed in the EJB
    component's interface
    2.Abstract accessor/mutator methods are used to access and modify
    persistent state and relationship information for entity objects
    3.Abstract Accessor/Mutator methods do not throw exceptions
    4.The EJB developer must implement the Accessor/Mutator methods
    5.Abstract accessor methods may or may not be exposed in the EJB
    component's interface
    2.Which ONE of the following is true?
    Choose the best answer:
    1.Local interfaces cannot have a relationship with other Entity
    components
    2.Local interfaces cannot be used for Stateless Session EJB
    3.Local interfaces can be a part of Object's persistent state
    4.Local interfaces have the same functionality as that of a
    stateless Session EJB
    3.Which of the following describe the <cmr-field> in a EJB 2.0
    descriptor?
    Choose all correct answers:
    1.A Local interface/Entity can be a value of a <cmr-field>
    2.There is no <cmr-field> in EJB 2.0 descriptor
    3.It is used to represent one meaningful association between any
    pair of Entity EJBs, based on the business logic of the Application
    4.It provides a particular mapping from an object model to a
    relational database schema
    5.It allows the Local Entity interfaces to participate in
    relationships
    4.Which of the following are the advantages of using Local interfaces
    instead of dependent value classes?
    Choose all correct answers:
    1.Local Entity Interfaces can participate in Relationships
    2.The life cycle of Local Entity Interfaces is managed by EJB
    container, intelligently
    3.Local Entity Interfaces can be used in EJB QL Queries
    4.Local Entity Interfaces can be a part of the <cmp-field> but not
    <cmr-field>
    5.Which of the following are true about Local interfaces
    1.A local interface must be located in the same JVM to which the EJB
    component is deployed
    2.Local calls involve pass-by-reference.
    3.The objects that are passed as parameters in local interface
    method calls must be serializable.
    4.In general, the references that are passed across the local
    interface cannot be used outside of the immediate call chain and must
    never be stored as part of the state of another enterprise bean.
    6.Which of the following specifies the correct way for a client
    to access a Message driven Bean?
    Choose the best answer:
    1. via a Remote interface
    2. via Home interface
    3. Message driven bean can be accessed directly by the client
    4. both 1 & 2
    5. none of the above
    ------------------------------------------------------------------------7.Which of the following statements are true about message-driven
    bean Clients?
    ------------------------------------------------------------------------Choose all correct answers:
    They can create Queue and QueueConnectionFactory objects
    They can create Topic and TopicConnectionFactory objects
    They can lookup the JNDI server and obtain the references for
    Queue and Topic and their connection Factories
    Only 1 and 2 above

    Hi guys I'm beginner to EJB and i got some unanswered
    questions.
    Can any one of you please.. give answers?
    Thanks if you do...
    Which of the following are true about abstract methods
    in EJB 2.0
    CMP?
    Choose all correct answers:
    1. Abstract accessor methods should not be exposed
    d in the EJB
    component's interfacefalse
    2.Abstract accessor/mutator methods are used to
    access and modify
    persistent state and relationship information for
    entity objectstrue
    >
    3.Abstract Accessor/Mutator methods do not throw
    exceptionstrue
    >
    4.The EJB developer must implement the
    Accessor/Mutator methodsfalse
    5.Abstract accessor methods may or may not be exposed
    in the EJB
    component's interfacetrue
    2.Which ONE of the following is true?
    Choose the best answer:
    1.Local interfaces cannot have a relationship with
    other Entity
    componentsfalse
    2.Local interfaces cannot be used for Stateless
    Session EJBfalse
    3.Local interfaces can be a part of Object's
    persistent statefalse
    4.Local interfaces have the same functionality as
    that of a
    stateless Session EJBtrue
    3.Which of the following describe the <cmr-field> in a
    EJB 2.0
    descriptor?
    Choose all correct answers:
    1.A Local interface/Entity can be a value of a
    <cmr-field>true
    2.There is no <cmr-field> in EJB 2.0 descriptorfalse
    3.It is used to represent one meaningful association
    between any
    pair of Entity EJBs, based on the business logic of
    the Applicationtrue
    4.It provides a particular mapping from an object
    model to a
    relational database schematrue
    5.It allows the Local Entity interfaces to
    participate in
    relationshipstrue
    4.Which of the following are the advantages of using
    Local interfaces
    instead of dependent value classes?
    Choose all correct answers:
    1.Local Entity Interfaces can participate in
    Relationshipsis
    2.The life cycle of Local Entity Interfaces is
    managed by EJB
    container, intelligentlyis
    3.Local Entity Interfaces can be used in EJB QL
    Queriesnot
    4.Local Entity Interfaces can be a part of the
    <cmp-field> but not
    <cmr-field>not
    >
    >
    5.Which of the following are true about Local
    interfaces
    1.A local interface must be located in the same JVM
    M to which the EJB
    component is deployedtrue
    2.Local calls involve pass-by-reference.true
    3.The objects that are passed as parameters in local
    l interface
    method calls must be serializable.false
    4.In general, the references that are passed across
    s the local
    interface cannot be used outside of the immediate
    e call chain and must
    never be stored as part of the state of another
    r enterprise bean.true
    >
    6.Which of the following specifies the correct way for
    a client
    to access a Message driven Bean?
    Choose the best answer:
    1. via a Remote interfacefalse
    2. via Home interfacefalse
    3. Message driven bean can be accessed directly by
    the clientfalse
    4. both 1 & 2false
    5. none of the abovetrue.
    >
    ----------------7.Which of the following statements
    are true about message-driven
    bean Clients?
    ----------------Choose all correct answers:
    They can create Queue and QueueConnectionFactory
    objectsthe container can, dunno bout clients
    >
    They can create Topic and TopicConnectionFactory
    objectsthe container can, dunno bout clients
    >
    They can lookup the JNDI server and obtain the
    references for
    Queue and Topic and their connection Factories
    true
    Only 1 and 2 abovefalse
    somebody correct me if i'm wrong

  • Where can I find the detail document about certain method of a class?????

    Moved to correct forum by moderator
    Hi everyone,
    where can I find the detail document about certain method of a class?????
    e.g.  the class CL_GUI_ALV_GRID , when I was going through the class and looking
    at the methods, sometimes the method description is just like the method name,
    and I cannot know what the method does. 
      so, I am wondering  where I can find the detail information about the class???
    Edited by: Matt on Dec 4, 2008 11:55 AM

    Hi,
    Most of the times the SAP itself provides the documentaion of the CLASS. when you click on the METHOD name the METHOD DOCUMENTATION button you can see on the application tool bar.
    more over the names of the methods suggest what it is going to do.
    SET_ATTRIBUTE( sets the attribute)
    GET_ATTRIBUTE( gets the attribute value that is provided to the method)
    GET_CHILDNODE
    BIND_TABLE
    etc
    like this
    regards
    Ramchander Rao.K

  • 'System.AccessViolationException' occurred in method 'Read' of class 'OpsDa

    Exception Stack Trace:_
    An exception of type *'System.AccessViolationException'* occurred in method *'Read' of class 'OpsDac'*
    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
    The stack trace given is: at Oracle.DataAccess.Client.OpsDac.Read(IntPtr opsConCtx, IntPtr opsErrCtx, IntPtr opsSqlCtx, IntPtr& opsDacCtx, OpoSqlValCtx* pOpoSqlValCtx, OpoMetValCtx* pOpoMetValCtx, OpoDacValCtx* pOpoDacValCtx) at Oracle.DataAccess.Client.OracleDataReader.Read()
    Environment Details:_
    Oracle Database- Oracle Database 11g Enterprise Edition Release 1 (11.1.0.6) Patch set 11.1.0.7
    ODP.NET- ODTwithODAC1110621- Oracle Data Access Components for Oracle Client 11.1.0.6.21
    Downloaded ODP.NET from the below link- http://www.oracle.com/technology/software/products/database/oracle11g/111060_win32soft.html
    *.NET Framework* – v3.5
    ORM layer (Object Relation Mapping) - NHibernate (it is the data access layer used in my project- which internally uses ADO.NET in the background)
    Coding Language - C#
    Test Case:*
    I don’t have a particular test case for this exception, but below is the similar code that caused the exception.
    Code:_
    void Main()
    //Placeholder for saving ID of new record that is saved through ADO.
    static decimal ADOSavedObjectID;
    private ADONewTestRecord obj = new ADONewTestRecord();
    //ADO.NET code to save this returns saved object db ID.
    ADOSavedObjectID = SaveThroughADOViaNHibernate(obj);
    //Fetch the Saved record through NHibernate.
    TestNewRecordFromNHibernateViaADO = GetTestRecordThroughNHibernateViaADO(ADOSavedObjectID )
    public decimal SaveThroughADOViaNHibernate(ADONewTestRecord obj)
    //here we have NHibernate API to save the record which uses ADO.NET (sorry I am not providing any lines of code, as I don’t have the source code of NHibernate that is accessing –ADO.NET )
    public TestNewRecordFromNHibernate
    GetTestRecordThroughNHibernateViaADO(decimal ADOSavedObjectID)
    // here we have NHibernate API to fetch the record which uses ADO.NET (sorry I am not providing any lines of code, as I don’t have the source code of NHibernate that is accessing –ADO.NET )
    // Exception is raised.
    Please share your thoughts on this exception in ODP.NET, and request me if you need any additional details.
    Thanks

    Hi,
    How often does this occur? Is this consitently reproducible with certain code? Is it always that code that has the problem? Can you generally reproduce this in a test environment?
    For issues regarding 3rd party libraries that cannot be reproduced with a source code testcase, I'd generally recommend testing latest software versions if that's an option.
    If the behaivor still occurs on current versions, it may be best to open a SR with support so we can get some tracing, and also a memory dump of the access violation to see if we can match it to known issues. You can get a memory dump via setting ODP tracing to level 8, or also via the use of adplus, debugdiag, etc.
    Hope it helps, but realize it may not,
    Greg

  • Abstract methods in ByteBuffer class

    I'am a little confused with abstract methods get() and put() in ByteBuffer class.
    Java API says:
    public abstract class ByteBuffer
    extends Buffer implements Comparable
    // This is a partial API listing
    public abstract byte get( );
    public abstract byte get (int index);
    public abstract ByteBuffer put (byte b);
    public abstract ByteBuffer put (int index, byte b);
    }Question is:
    How can I call methods get() and/or put() when they are abstract - not implemented in ByteBuffer class?
    Thanks

    Yeah, it's a subclass of ByteBuffer. You can find out more about the class by using introspection.
    But, you don't have to, to use this API. This is called "design-by-contract" (well, part of it anyway), and that's why the class is hidden with respect to the API docs. The idea is that an API is kind of like a contract, an agreement between the designer and the user of the API. The user of the API is given just what s/he needs to do the job. The designer might implement the API with more stuff that is immediately apparent, but the user doesn't need to know that stuff to use the API. This provides a good layer of abstraction around the API and makes code more flexible.
    So, it's good to know how these things work -- that the ByteBuffer contract is serviced by hidden implementing classes -- but you don't have to know that to use ByteBuffer, and in fact you'd probably only make things difficult (buggy and hard to maintain) if you wrote code that used the fact that apparently the implementing subclass of ByteBuffer is HeapByteBuffer.

  • Newbie question about abstract methods

    hey, I'm working on a web application that I was given and I'm a little confused about
    some of the code in some of the classes. These are some methods in this abstract class. I don't understand
    how this post method works if the method it's calling is declared abstract. Could someone please tell me how this works?
        public final Representation post(Representation entity, Variant variant) throws ResourceException {
            prePostAuthorization(entity);
            if (!authorizeGet()) {
                return doUnauthenticatedGet(variant);
            } else {
                return doAuthenticatedPost(entity, variant);
    protected abstract boolean authorizeGet();Thanks
    Edited by: saru88 on Aug 10, 2010 8:09 PM

    Abstract Methods specify the requirements, but to Implement the functionality later.
    So with abstract methods or classes it is possible to seperate the design from the implementation in a software project.
    Abstract methods are always used together with extended classes, so I am pretty sure that you are using another class.
    Btw: Please post the Code Keyword in these brackets:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    

  • Abstract Method in a Class with implemented method

    I have a class which already has methods Implemented.I mean thse metgods are not abstract.I want only one method to be abstarct which will be overrideen by its subclass or derived Class
    I have never tried this
    Does anyone knows how to do this
    If yes could you give me syntax of the method
    Thanks in advance
    CSJakharia

    javax.swing.JComponent is an example of an abstract
    class with no abstract methods. That is why the
    following works:
    JComponent component = new JComponent(){};
    Not to forget you cannot instantiate abstarct classes
    public abstract class Test
    public String getName()
    return "Mike";
    public static void main(String[] args)
    Test tt = new Test();
    System.out.println(tt.getName());
    }and you would get the error
    The type Test cannot be instantiated.
    You remove the abstract keyword and it would compile
    good.No I am not misinterpreting I know what he is saying but I am closing the door of misinterpretation which I felt was possible. ;)
    cheers

  • Implement abstract method from base class problem

    Here is the example:
    public abstract class AbstractClass{
    protected double aVariable;
    protected abstract double abstractMethod();
    public class RealClass extends AbstractClass{
    public double abstractMethod(){
    return aVariable;
    Error message:
    RealClass should be declared abstract; it does not define abstractMethod() in AbstractClass

    I also compiled the code with Jdk1.3 and it
    worked.. The code would not have compiled
    if the access modifier in the derived class
    was more restrictive(eg private )...

  • About abstract method

    Hi, there are many abstract methods In the abstract java.awt.Graphics class. when I write a class extends Component(for example JPanel), override the paint(Graphics g) method, then I can invoke the abstract methods in the Graphics class to draw in my Component.
    So I think there is a class extends the Grahpics class, but is secret to us. and the JDK designer how to design these class structor?
    Thanks a lot,
    Regards.

    The reason that why most of the methods of the Graphics class are abstract is because to have an implementation for them, the underlying platform must be used, for example: g.drawLine(0,0,100,100) would on Linux end up on the native side making the call:
    XDrawLine(display,drawable,gc,0,0,100,100);whereas on Windows it would be something else. There is not platform independent way to draw on the screen.
    Tuomas Rinta

  • Abstract method and class

    I'm a beginner in Java and just learn about abstract method and class.
    However, i am wondering what is the point of using abstract method/class?
    Because when I delete the abstract method and change the class name to public class XXXX( changed from "abstract class XXXX), my program still runs well, nothing goes different.
    Is it because I haven't encountered any situation that abstract method is necessary or ?
    Thanks!

    Yes - you probably haven't encountered a situation where you need an abstract.
    Abstract classes are not designed to do anything on their own. They are designed to provide a template for other classes to extend by inheritance. What you have build sounds like a concrete class - one which you are creating instances of. Abstract classes are not designed to be ever instantiated in their pure form - they act like a partial building block, which you will complete in a class which extends the abstract.
    An example might be a button class, which provides some core functionality (like rollover, rollout etc) but has an empty action method which has to be overwritten by a relevant subclass like 'StartButton'. In general, abstract classes may not be the right answer, and many people would argue that it is better to use an interface, which can be implemented instead of extended, meaning that you can ADD instead of REPLACING.
    Not sure if that helps.. there are whole chapters in books on this kind of thing, so it's hard to explain in a couple of paragraphs. Do some google searches to find out more about how they work.

  • Overiding super class method to an abstract  method

    public class Super
    public void doSomethingUseful()
    public abstract class Sub extends Super
    public abstract void doSomethingUseful();
    What is the OO principle behind this?
    When do we need to override a super class method in subclass as an abstract?

    Lets first look at a simple design pattern called "Template Method".
    public abstract class Library
    private void collectBooks()
    // collect books here
    private void putBookInShelf()
    // put books in shelf here
    // abstract method sortBooks()
    public abstract void sortBooks();
    public void processBooks()
    collectBooks();
    sortBooks();
    putBooksInShelf();
    this class is an abstract class giving an abstract method called "sortBooks()", what is it useful for? We can make a subclass and implement sortBooks() to sort the books as we want (title wise, author wise, date wise, publisher wise) and then simply call processBooks() to process them.
    One Sub class may look like:
    public class MyLibrary extends Library
    public void sortBooks()
    // sort books by title b/c I like them sorted out by title
    Another sub-class may look like
    public class HisLibrary extends Library
    public void sortBooks()
    // sort books by Author, b/c he likes his books sorted out by author
    Now client will say:
    public static void main(String str[])
    MyLibrary mylib=new MyLibrary();
    mylib.processBooks(); // books will be processed by sorting them title wise
    HisLibrary hislib=new HisLibrary();
    hislib.processBooks(); // books will be processed by sorting them author wise
    So in Library class, method "sortBooks()" was a template method allowing subclasses to sort the books as they want while all other functionality was implemented by Library class itself.
    Now if we go back to your example, a method which is concrete in super class that you converted into an abstract method in sub class ( doSomethingUseful() ) is now a template method, which alows the sub classes of this subclass to do something useful what they think is useful or in other words you are allowing subclasses of this subclass to implement this template method as they want by using their own algorithm.
    Now why whould you do that? answer is that you don't have access to the code of super class, otherwise you must have made this method abstract in super class in the first place.
    Note that the code may not compile, I tried to come up with an exmple and did not pay attention to compiler demands.
    I think I cleared my point, It was tough to explain though.
    Good Luck.
    Khawar.

  • Superclass and subclass and abstract method

    Hi all,
    I am a little bit confused about abstract methods.
    I define a superclass without abstract keyword and an abstract method inside the superclass. Then I write a subclass to extend the superclass.
    When I compile the source code I get error. It looks like I can't initiate an instance from the supercalss and/or subclass. If I put abstract key word in the superclass definition there is no problem at all. So my question: does abstract method needed to be defined in an abstract superclass only?
    Thank for you input.

    Abstract methods can only be declared in an abstract class.

Maybe you are looking for

  • Officejet Pro 8500 A909a cartrige error message

    I just changed the color ink cartriges on my Officejet Pro 8500 A909a ( with new hp ink) and now the display says "the following ink cartrige appears to be missing or damaged.  I have tried repeatedly to re-insert it with no change.  It now also says

  • Unable to open D3 NEF in CS3 (Mac) and CS2 (Win)

    I have installed the latest Camera Raw Update file (Mac OSX 10.5.3), but when I try to open a nef-file that was taken with my Nikon D3, CS3 complains about an invalid file type - ??? Opening the same file in Nikon NX works without a problem. A friend

  • Installing Logic Studio 9 upgrade issue

    I am installing the Logic Studio 9 upgrade from a copy of Logic Pro 7 which itself is an upgrade from Logic Express 7. I can run it usung the XSKey but when I try to run it without, it asks for a valid serial number (from Logic Pro 7) to verify the u

  • Need help on Oracle Adverse Event Reporting System

    Hi, From where I can download "Oracle Adverse Event Reporting System". Please give me the link. I have no option, rather than postion in Database-General form. Thanks Naveen.

  • SQL 2005 Distributed Transactions from WCF

    Hello, I've been redirected here from the Transaction Programming forum becuase I have e peculiar issue with SQL 2005 running INSERT stored procs from multiple WCF services all withing a TransactionScope. The original post is http://forums.microsoft.