Announcement

Collapse
No announcement yet.

[HELP] Java programming

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [HELP] Java programming

    I need a bit of help with some simple Java code... (I have no helps installed over my machine, so I'm doing blindly-coding )

    However, this is the problem:
    I have an object, call it objX.
    objX has a method Save that return an IStream. IStream is an Interface, so I cannot instantiate an IStream Object.
    But, I have found some infos saying that I simply can pass to the Save method one of the numerouses objects supporting the IStream interface.

    Now, I really know nothing of Java's available objects...so I dunno which objects support the IStream interface



    Uh, and the final thing: I need an object that can solve the problem above, ok, BUT I need that this object is a memory stream that can return me its content in a String object.


    Heeeeelp meeeeee....
    Sat on a pile of deads, I enjoy my oysters.

  • #2
    Erm, why aren't you just returning a string or a pointer to a string?

    - Gurm
    The Internet - where men are men, women are men, and teenage girls are FBI agents!

    I'm the least you could do
    If only life were as easy as you
    I'm the least you could do, oh yeah
    If only life were as easy as you
    I would still get screwed

    Comment


    • #3
      There is always java.sun.com for all your Java language reference.
      Just search which class is derived from IStream (for your need).

      EDIT:
      Actually... are you referring to InputStream? Cause IStream seems more like a C# thing to me

      EDIT:
      Or just objX.save().toString() perhaps?
      Last edited by WyWyWyWy; 8 February 2003, 21:37.
      P4 Northwood 1.8GHz@2.7GHz 1.65V Albatron PX845PEV Pro
      Running two Dell 2005FPW 20" Widescreen LCD
      And of course, Matrox Parhelia | My Matrox histroy: Mill-I, Mill-II, Mystique, G400, Parhelia

      Comment


      • #4
        Originally posted by WyWyWyWy
        There is always java.sun.com for all your Java language reference.
        Just search which class is derived from IStream (for your need).

        EDIT:
        Actually... are you referring to InputStream? Cause IStream seems more like a C# thing to me

        EDIT:
        Or just objX.save().toString() perhaps?
        it's:
        void objX.Save(objIStream);


        It wants a pointer to a Stream Object...
        Sat on a pile of deads, I enjoy my oysters.

        Comment


        • #5


          There isn't any IStream or ObjIStream interface in there though.
          Gigabyte GA-K8N Ultra 9, Opteron 170 Denmark 2x2Ghz, 2 GB Corsair XMS, Gigabyte 6600, Gentoo Linux
          Motion Computing M1400 -- Tablet PC, Ubuntu Linux

          "if I said you had a beautiful body would you take your pants off and dance around a bit?" --Zapp Brannigan

          Comment


          • #6
            Thats why I asked is he referring to InputStream, which is NOT an interface but an abstract class.
            P4 Northwood 1.8GHz@2.7GHz 1.65V Albatron PX845PEV Pro
            Running two Dell 2005FPW 20" Widescreen LCD
            And of course, Matrox Parhelia | My Matrox histroy: Mill-I, Mill-II, Mystique, G400, Parhelia

            Comment


            • #7
              The only references to IStream I can find, are to com.ms.com.IStream: apparently some Microsoft VisualJ++ thingy. Could that be what you're trying to use?

              If so: I can't really find any docs (only done a quick Google). It seems to be either proprietary, or dead. Or both

              Martin

              Comment


              • #8
                J++, that's something I haven't seen mentioned in a looong time. That would make sense because if I recall from my VisualBasic days MS tutorials used objX a lot.
                Gigabyte GA-K8N Ultra 9, Opteron 170 Denmark 2x2Ghz, 2 GB Corsair XMS, Gigabyte 6600, Gentoo Linux
                Motion Computing M1400 -- Tablet PC, Ubuntu Linux

                "if I said you had a beautiful body would you take your pants off and dance around a bit?" --Zapp Brannigan

                Comment


                • #9
                  I am a little rusty as I am nolonger teaching or working in Java, I have never used the IStream (from MS) and I’m now working exclusively in C#, but this might help...

                  Originally posted by Drizzt
                  it's:
                  void objX.Save(objIStream);

                  It wants a pointer to a Stream Object...
                  I thought you said it returns a Stream. The above returns nothing. A bit confusing. Can you clear this up?

                  Next I am not sure that I'm completely understanding you, are you asking how to use the IStream interface (form MS) or are you trying to use an InputStream (standard Java)? They are different.

                  If you are going for the first then…

                  1) You might need to find an IStream factory to generate the IStream object. Generally Streams are returned from another method (that is the factory). An example is opening a file you generally hand off a file name and an IO Stream is returned (a generalization). You need to look for a method that returns an IStream. Then it is as simple as :

                  IStream myIStream = someObject.someMethod(someParameter);

                  So you can look for an IStream factory. Good luck.

                  ---
                  Or
                  ---

                  2) Create a class that extends the IStream interface. Setup the required methods. Then just create an object of the new class and pass it in. Polymorphism will insure it works.
                  I found this on msdn.Microsoft.com…


                  and


                  Now if you are looking for a how-to on general IO Streams then any Stream factory will work you just need to find the correct one for your purpose. For example sockets return InputStreams as such.

                  InputStream iStream = socket.getInputStream();

                  I found examples here:


                  You might want to pick up a copy of the JavaIO book from O'Reilly. It covers many of the different stream types found in Java.


                  Did this help at all? Can you ask your question in another way that might clear up the confusion?


                  Jeff
                  -We stop learning when We die, and some
                  people just don't know They're dead yet!

                  Member of the COC!
                  Minister of Confused Knightly Defence (MCKD)

                  Food for thought...
                  - Remember when naps were a bad thing?
                  - Remember 3 is the magic number....

                  Comment


                  • #10
                    Ok, a few clarifications.

                    This is a problem with M$ and VJ6++, so standard Java has nothing to do with it (unfortunately).


                    There is an object wich works as a data container in M$ ADO that can save it's content as a sequence of byte (a string, in the end).

                    This sequence of byte, if stored somewhere, can be reloaded into another object of the same type, in any moment from any PC, without the needing of the original database (wich generated the datas) (argh...explaining the entire problem in english is a bit painfuly...Gurm, please, don't be too bad!)


                    Now, this object has two Save methods
                    .Save(com.ms.com.Istream)
                    or
                    .Save(String)


                    The first is the huge problem: the only thing that the docs say is that you can use any of the objects supporting the IStream Interface. Only problem, there is no list of such objects.
                    And, there is no word about it all over the net!


                    The second method works really easily. You pass a string containing the name of a file, and the bytes are saved there.
                    Maybe this is my only fast way to get out of the problem: I save the datas to a temp file, then read back in a String, and store them where I really need.
                    Only problem here: is there a Java function that give me the name of a temp file? I mean...maybe my proggie will need to create more of this files at the same time; so, I need a new name I'm sure it will be unique.


                    Any help appreciated!
                    Sat on a pile of deads, I enjoy my oysters.

                    Comment


                    • #11
                      Ohhh... so its a Platform SDK thing, not a Java thing :T

                      What Duty said is right, just define a class that implements IStream, then you're fine.

                      Something like this
                      public class oh_man extends IStream

                      Check out Duty's links.
                      P4 Northwood 1.8GHz@2.7GHz 1.65V Albatron PX845PEV Pro
                      Running two Dell 2005FPW 20" Widescreen LCD
                      And of course, Matrox Parhelia | My Matrox histroy: Mill-I, Mill-II, Mystique, G400, Parhelia

                      Comment


                      • #12
                        Generally if I am going to use something like what you are describing, I setup my own factory (if there isn't one). You might want to look in to it. It can make future programming easier if you need this type if object in the future. Let us know if you need any more help. I don't post often but I am here most everyday.


                        Jeff
                        -We stop learning when We die, and some
                        people just don't know They're dead yet!

                        Member of the COC!
                        Minister of Confused Knightly Defence (MCKD)

                        Food for thought...
                        - Remember when naps were a bad thing?
                        - Remember 3 is the magic number....

                        Comment


                        • #13
                          Hi!

                          Actually you don not extend an interface but implement it.

                          public class Yclass implements IStream {
                          ....
                          }

                          You are then forced to implement the methods declared in the IStream interface.

                          I don not no anything about the Interface you are describing. To implement it you have to know which methods to implement.

                          (Perhaps another helpful example regarding interfaces:
                          In suns jdk you have the Runnable interface used for thread programming. To use this interface you just implement it by defining the run() method.)

                          /Leo
                          AMD Athlon64 X2 4200+
                          Asus A8N-E
                          Corsair TWINX2048-3200C2
                          Asus Extreme GeForce N7800GT
                          Seagate Barracuda 7200.8 250GB
                          Lian-Li PC60
                          Windows XP Pro 64bit

                          Comment


                          • #14
                            I said I'm a bit rusty. Funny thing is I use to doc points from students for making that same mistake (implements <-> extends)


                            Jeff
                            -We stop learning when We die, and some
                            people just don't know They're dead yet!

                            Member of the COC!
                            Minister of Confused Knightly Defence (MCKD)

                            Food for thought...
                            - Remember when naps were a bad thing?
                            - Remember 3 is the magic number....

                            Comment


                            • #15
                              Am I that student?
                              I made this mistake many times already.
                              P4 Northwood 1.8GHz@2.7GHz 1.65V Albatron PX845PEV Pro
                              Running two Dell 2005FPW 20" Widescreen LCD
                              And of course, Matrox Parhelia | My Matrox histroy: Mill-I, Mill-II, Mystique, G400, Parhelia

                              Comment

                              Working...
                              X