comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * When I use setFont( ) method to set the string'sfont, the result font is another one. - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bc656b18a2c6cc1 * Applet & IE - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2726d23c9ba56a6 * RPC from C++-Client to a Java-Server - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ac99ac85e15a47f8 * Can Java Programmer Learn C++ Quickly? - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec * LAMP & J2EE as opposed to LAMP vs J2EE - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/33c89ba6522432dc * Is that to implement JProgessBar, we need do in different thread? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b82cc98adac6a8bf * Factorizing BigIntergers - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f4c9e53a34cd1b31 * A file filter question - 3 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c83d2ec52c63d48f * Eclipse Plugin to post HTTP - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/be420b259b459ffe * html to jpg/gif converter - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5fc212472e59ad72 * profiling software recomendation - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/15be839996c5e520 * Help with unknown source for exception - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/58929f7563fac00a * RSA ciphered streams problem - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/50273190505df7bd * J2EE limitations and disadvantages - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/766f4a45892b9603 * Throws exception into Threads - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/428bfb21eed9b38f * shallow copying an ArrayList in Java 5 - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9fd987b2d708a308 * File copy through RMI - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bd23301f7b38b8df ============================================================================== TOPIC: When I use setFont( ) method to set the string'sfont, the result font is another one. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bc656b18a2c6cc1 ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 3:14 pm From: "VK" > private m_font = new Font("bold",Font.BOLD, 18); "bold" is an actual font name? is it installed properly on the machines of question? ============================================================================== TOPIC: Applet & IE http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/2726d23c9ba56a6 ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 6:36 am From: [EMAIL PROTECTED] (Damien) Hi, I would like to know how to write a java applet able to access to a dll with the default IE JRE (1.1). This applet must also work on Netscape and other browsers. Thanks a lot, Damien ============================================================================== TOPIC: RPC from C++-Client to a Java-Server http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/ac99ac85e15a47f8 ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 4:12 pm From: "Oliver Hirschi" Hi, I have to implement a Client-Server-Architecture. A C++ client should call a remote method (with a few of String parameters) on a java client and get back a boolean value. I think I am a little confused. Which architecture should I take? Do I have to use CORBA, or is there an alternative (RMI, ...)? Thanks. -- Oliver Hirschi http://www.FamilyHirschi.ch ============================================================================== TOPIC: Can Java Programmer Learn C++ Quickly? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/7c7a28aa864e41ec ============================================================================== == 1 of 2 == Date: Mon, Dec 13 2004 8:25 am From: Chris Smith Chris Uppal <[EMAIL PROTECTED]> wrote: > I agree, the better way to describe it as that the "constructor has not > finished". Your statement is undoubtedly true, but it sort of misses the point. The whole point of saying that the constructor has not yet started is to point out that no initialization will have occurred, beyond the setting of all attributes to default values of 0, null, or false. If you consider the superclass constructor call to be part of the constructor (which I generally don't) then you could say something more complex, like "before any part of the constructor has run except its superclass constructor invocation." -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation == 2 of 2 == Date: Mon, Dec 13 2004 5:48 pm From: "Chris Uppal" Chris Smith wrote: > > I agree, the better way to describe it as that the "constructor has not > > finished". > > Your statement is undoubtedly true, but it sort of misses the point. Are you suggesting that /pedantry has no place on Usenet/ ?!? Actually there was a point to that bit of my post, indeed two of them, which I suppose I could have put more emphasis on, but I utterly refute and deny the idea that any such emphasis was necessary ;-) Still... One is is that the thread (overall) has wandered into places where posters are asking for clarification of technical details. In such circumstances it seems (to me) obligatory that we dispense with approximation. The other is that -- from a staightforward "how to structure the code" POV -- it's important to realise that the object can be (and typically will be) /partially/ initialised at the time when an overriding method is called. -- chris ============================================================================== TOPIC: LAMP & J2EE as opposed to LAMP vs J2EE http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/33c89ba6522432dc ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 10:59 am From: "Ross M. Greenberg" I'm considering starting off discussing LAMP and its interpretive nature as opposed to J2EE's compiled nature......... "Steve Sobol" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ross M. Greenberg wrote: > > I'm trying to investigate the pros & cons on LAMP and J2EE for an article > > I'm writing. What do you think of LAMP as a platform? J2EE? > > I use both. I'm a recent convert to the J2EE way of doing things, and have done > PHP projects since 1998, but I find both useful. > > > -- > JustThe.net Internet & New Media Services, http://JustThe.net/ > Steven J. Sobol, Geek In Charge / 888.480.4NET (4638) / [EMAIL PROTECTED] > PGP Key available from your friendly local key server (0xE3AE35ED) > Apple Valley, California Nothing scares me anymore. I have three kids. ============================================================================== TOPIC: Is that to implement JProgessBar, we need do in different thread? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/b82cc98adac6a8bf ============================================================================== == 1 of 1 == Date: Fri, Dec 10 2004 12:52 pm From: "Daniel Grieves" Not sure I understand your question but here is what I do when using the JProgressBar: 1) As a previous post explained, if you call setValue() from the event-handling thread, the component will not update until you release the event-handling thread. This means that you cannot be performing your time-consuming task on the event-handling thread (usually a bad idea anyway) so start another thread and do the heavy lifting there. 2) If you call setValue() from any thread _other_ than the event-handling thread, you are (to the best of my knowledge) breaking the contract that a method call to a visible Swing component must be made from the event-handling thread. So as you're cruising along in a different thread, performing a time-consuming task, any calls you make to setValue() must be put onto the event-handling thread. The easiest way to do this is to use the SwingUtilities.invokeLater() method. 3) If you use this method often enough, eventually you will decide to sub-class JProgressBar and provide your own thread-safe alternative to the setValue() method. Dan "James" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > without using antoher thread, there is no way to do it right? > when something is processing, it will not response to progressbar? > anyone can give some example(code) on it? > eg. like processing for loop 10000 time > the progress bar showing the percentage. > > ============================================================================== TOPIC: Factorizing BigIntergers http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/f4c9e53a34cd1b31 ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 6:03 pm From: "Stefan Schulz" Hello World ;) I need to factorize BigInteger objects. (About 256 bits). Since it is probably not wise to attempt to do that in any trivial way, and i don't have time to find and implement a good algorithm, does anone amoung you know a library that supports this kind of operation? See you Stefan -- Whom the gods wish to destroy they first call promising. ============================================================================== TOPIC: A file filter question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c83d2ec52c63d48f ============================================================================== == 1 of 3 == Date: Mon, Dec 13 2004 10:06 am From: The Abrasive Sponge mikeotp wrote: > Thank you. > May god be with you. Can I help even though I am agnostic? public class MyFilter extends FilterReader { //method removes all 'a' characters public int read() { char c = super.read(); if (c == 'a') { return this.read(); } } } I haven't compiled this...but clean it up, compile and attach it to a FileReader and give it a try. == 2 of 3 == Date: Mon, Dec 13 2004 10:12 am From: The Abrasive Sponge The Abrasive Sponge wrote: > mikeotp wrote: > > >> Thank you. >> May god be with you. > > > Can I help even though I am agnostic? > > public class MyFilter extends FilterReader { > //method removes all 'a' characters > public int read() { > char c = super.read(); > if (c == 'a') { > return this.read(); > } > } > > } > > I haven't compiled this...but clean it up, compile and attach it to a > FileReader and give it a try. > > public class MyFilter extends FilterReader { //method removes all 'a' characters public int read() { char c = super.read(); if (c == 'a') { return this.read(); } else { return c; //Correction } } } == 3 of 3 == Date: Mon, Dec 13 2004 8:56 am From: [EMAIL PROTECTED] (mikeotp) regards: ------------------------------------------------------------------ public FileOutputStream doFunction(FileInputStream file1) { <--codes to filter some specific characters or String in file1--> <-- example following: characters:a String:<test> --> } FileOutputStrea is different from FileInputStream by some specific characters or String. ------------------------------------------------------------------ How can I compose my code?^^ Any suggestions is welcome. Thank you. May god be with you. ============================================================================== TOPIC: Eclipse Plugin to post HTTP http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/be420b259b459ffe ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 9:28 am From: [EMAIL PROTECTED] Looking for an eclipse plugin (with source code preferibly) that will allow me to post an HTTP request. I am trying to integrate with a proprietary Server side app and want to be able to pass a large string as a parameter to a JSP page. Any help is greatly appreciated jason ============================================================================== TOPIC: html to jpg/gif converter http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/5fc212472e59ad72 ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 7:12 am From: [EMAIL PROTECTED] HtmlSnapshot is for server and programmer usage. If you want a normal application, Try Html To Image http://www.guangmingsoft.net/htmltoimage/help.htm Its features: Directly save the webpage at a given URL into image in bmp, jpeg, tiff, gif or png format. Create thumbnail images from large images. Batch conversion is supported. Integrate with Internet Explorer's context menu. Support converting local HTML, MHT, TXT files to image. Support JPEG compression level Support capturing site with flash content. Run at background, web pages don't need to be displayed for capturing. Ming ============================================================================== TOPIC: profiling software recomendation http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/15be839996c5e520 ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 8:49 am From: "yourkit team" > Allow me to contrast with YourKit. YourKit also is highly regarded, but > when they had a problem with the Mac JVM, the YourKit team essentially > said it was an Apple bug that they hoped got fixed someday. A similar > problem, when faced by e-j technologies, got a workaround that week, and > a permanent fix within the month. Unfortunately, there are some things that could not be worked around. But there are good news: upcoming version of YourKit Java Profiler (first early access build will be available by the end of December) will support Mac OS X. ============================================================================== TOPIC: Help with unknown source for exception http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/58929f7563fac00a ============================================================================== == 1 of 2 == Date: Mon, Dec 13 2004 8:41 am From: [EMAIL PROTECTED] I'm working on a GUI and keep getting the following error. I have no idea where to start looking since all the debugging infor is stripped out. Since I compile with debugging flags turned on, I can only assume this error is in one of the precompiled classes, but which one? If it helps, I'm using a 1.3.1_07 SDK/JRE from Sun. I'm compiling with the -O and -g flags. This error is rare, but when it happens it sometimes causes other weirdness, so I'd like to get rid of it if possible. Any suggestions? -Will ArrayIndexOutOfBoundsException: no such child: 39 at java.awt.Container.getComponent(Unknown Source) at javax.swing.JComponent.rectangleIsObscured(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintWithBuffer(Unknown Source) at javax.swing.JComponent._paintImmediately(Unknown Source) at javax.swing.JComponent.paintImmediately(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) == 2 of 2 == Date: Mon, Dec 13 2004 1:21 pm From: "John C. Bollinger" [EMAIL PROTECTED] wrote: > I'm working on a GUI and keep getting the following error. I have no > idea where to start looking since all the debugging infor is stripped > out. Since I compile with debugging flags turned on, I can only assume > this error is in one of the precompiled classes, but which one? If it The exception originates in the getComponent() method of java.awt.Container, which you can tell from the first "at" line in the stack trace. The rest of the trace shows the nested invocation contexts of that method. The exception happens in the AWT / Swing event dispatch thread, which no doubt relates to the accompanying weirdness you see (and probably also to weirdness you don't see). HOWEVER, although the exception originates from Container, that doesn't necessarily mean the bug is there. Indeed, it is far more likely that the bug is in your own code. (More below.) > helps, I'm using a 1.3.1_07 SDK/JRE from Sun. I'm compiling with the > -O and -g flags. This error is rare, but when it happens it sometimes > causes other weirdness, so I'd like to get rid of it if possible. Any > suggestions? > -Will > > ArrayIndexOutOfBoundsException: no such child: 39 > at java.awt.Container.getComponent(Unknown Source) Read the first part of the stack trace, especially the exception message, in the context of the immediate source (Container): "no such child". It sounds like some Component that is a Container is attempting to access a child component that it thinks it has but does not find. Assuming that the Swing and AWT classes are not buggy, what are the possibilities? Chief among them, from my point of view, are 1) a child component has been removed (or partly removed) without the Container recognizing it and 2) a child component has been added (or partly added) without the Container recognizing it If you are not mucking about unreasonably in the internals of Swing and AWT classes (so as to break them), then the "partly added" and "partly removed" alternatives make the most sense. This is possible, and not so unreasonable, because your program is multithreaded (as all AWT and Swing programs are). Let's continue a bit: > at javax.swing.JComponent.rectangleIsObscured(Unknown Source) > at javax.swing.JComponent.paint(Unknown Source) > at javax.swing.JComponent.paintWithBuffer(Unknown Source) > at javax.swing.JComponent._paintImmediately(Unknown Source) > at javax.swing.JComponent.paintImmediately(Unknown Source) See all those methods on JComponent? It looks like the problematic Container is in fact some kind of JComponent. The exception happens in the context of the JComponent painting itself, and one can surmise (from the rectangleIsObscured() part of the trace) that the JComponent is trying to examine its children to see what parts need to be repainted. Onward: > at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) > at > javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(Unknown > Source) > at java.awt.event.InvocationEvent.dispatch(Unknown Source) And here we see that all of that happens in the context of the dispatch of an InvocationEvent. The API docs will clue you in here that these are used in the AWT event subsystem to handle calls to EventQueue.invokeLater() and .invokeAndWait(). It is conceivable that other, internal facilities might also use them. The most likely external means of getting these invoked is SwingUtilities.invokeLater() and SwingUtilities.invokeAndWait(). The rest of the stack trace just shows that the event was dispatched during the normal course of the event dispatch thread's operation. > at java.awt.EventQueue.dispatchEvent(Unknown Source) > at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown > Source) > at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) > at java.awt.EventDispatchThread.pumpEvents(Unknown Source) > at java.awt.EventDispatchThread.run(Unknown Source) So what's happening here? You say the error is rare, and it looks to me like a data corruption problem. That has thread synchronization error written all over it. The first thing to do is to ensure that you don't muck with your GUI objects outside the event dispatch thread; doing so is likely the cause of your problem. If you want to modify GUI elements that are visible (whether or not they are obscured) then you _must_ do it in the event dispatch thread. You can cause a non-EDT thread to request such action of the EDT with use of the aforementioned SwingUtilities.invokeLater() and SwingUtilities.invokeAndWait(). If you need more help then very likely you will have to show some code. In that case construct a minimal self-contained, compilable example that exhibits the problem, and post that. John Bollinger [EMAIL PROTECTED] ============================================================================== TOPIC: RSA ciphered streams problem http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/50273190505df7bd ============================================================================== == 1 of 2 == Date: Mon, Dec 13 2004 8:24 am From: [EMAIL PROTECTED] Have you tried printing the output to the screen to make sure that something is being written? The only think I could think might be the problem is that there wasn't enough time to write the whole object. You might try two methods that use thread synchronization. That way, if the write operation and read operation are synchronized, then the read can't happen until the write is finished. == 2 of 2 == Date: Mon, Dec 13 2004 7:22 pm From: "Jakub Stuglik" You're right - I tried to put it on the screen and "big" objects aren't written to the stream - there's nothing on the screen after writing operation ( I also commented code lines responsible for reading the object to make sure there's enough time to write the whole object but it wouldn't help ). Do you maybe have any idea how to deal with such a problem? Thanks for any suggestions. Kuba ============================================================================== TOPIC: J2EE limitations and disadvantages http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/766f4a45892b9603 ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 9:00 am From: [EMAIL PROTECTED] (Sean Winship) Hello, I'm being pulled in to a J2EE project (application server, EJBs, JCA, the works). I have extensive Java experience (including JDBC, JMS, and servlets), but have thus far avoided full J2EE because my initial investigations of it led me to conclude that it is unnecessarily complex, and inelegant. It seems to be one of those techologies that force developers to spend more time fighting with it than solving the real business problem. Is this perception correct? To assist in my ramping up on this project, I would appreciate pointers to documented, real world experience. What problems does J2EE solve well? Where does it fall down? What is the cost relative to the benefits? Is it possible to use it only where it works well and to integrate it with alternatives, or is there too much coupling? I don't have the option of not using J2EE on this project, but I would like to know in advance where my fingers are likely to get pinched. Thanks, Sean ============================================================================== TOPIC: Throws exception into Threads http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/428bfb21eed9b38f ============================================================================== == 1 of 4 == Date: Mon, Dec 13 2004 9:25 am From: [EMAIL PROTECTED] (Fran Garcia) I´ve developped an applet that run Threads and I wanna handle the errors throwing exceptions. I´ve readen a lot of post and they comment that is impossible make it. But I´ve not found a good solution. Can anybody help me? Any suggestion would be appreciated! Best regards == 2 of 4 == Date: Mon, Dec 13 2004 7:08 pm From: Andrea Desole I would use a variable in the thread to let the threads communicate possible exceptions: class MyThread extends Thread { private Throwable exception = null; public Throwable getException() { return exception; } public void run() { try { // do things } catch ( Throwable t ) { exception = t; } } } public void foo() { MyThread t = new MyThread(); t.run(); t.join(); // or whatever is needed to know //that the thread is terminated t.sleep(); if ( t.exception() != null ) // error handling } Fran Garcia wrote: > I´ve developped an applet that run Threads and I wanna handle the > errors throwing exceptions. I´ve readen a lot of post and they comment > that is impossible make it. But I´ve not found a good solution. Can > anybody help me? > > Any suggestion would be appreciated! > > Best regards == 3 of 4 == Date: Mon, Dec 13 2004 7:11 pm From: "Stefan Schulz" On 13 Dec 2004 09:25:49 -0800, Fran Garcia <[EMAIL PROTECTED]> wrote: > I´ve developped an applet that run Threads and I wanna handle the > errors throwing exceptions. I´ve readen a lot of post and they comment > that is impossible make it. But I´ve not found a good solution. Can > anybody help me? > > Any suggestion would be appreciated! Disclaimer: I am not sure i understood what you want to do. If you do mean what i think you mean, then indeed it is not possible. You can't "push" an Exception into another Thread of execution. All Exceptions never leave their originating Thread. If you want to use the Exceptions to signal the Threads that they should stop working, you would do much better to check some "chancel" field in the Runnable every so often, and exit the thread if it ever becomes "true" -- Whom the gods wish to destroy they first call promising. == 4 of 4 == Date: Mon, Dec 13 2004 10:38 am From: "John C. Bollinger" Fran Garcia wrote: > I´ve developped an applet that run Threads and I wanna handle the > errors throwing exceptions. I´ve readen a lot of post and they comment > that is impossible make it. But I´ve not found a good solution. Can > anybody help me? Much depends on what you mean to do with such exceptions. One alternative is to create a subclass of ThreadGroup that overrides the uncaughtException() method (compatibly!) so that it does something useful to you. You then assign the threads created by your applet to an instance of this ThreadGroup. Do note that the uncaughtException method will be invoked by some unspecified thread in the JVM, which is probably not the thread wherein the exception was thrown, and surely not the applet's main thread (inasmuch as it has one). All that assumes you mean to do something different than handle exceptions by making appropriate use of Java's try / catch mechanism within the context of a single thread. If any of that fails to make sense to you, then you would be best off to study some of the basics of programming with threads, and possibly the basics of using exceptions. Writing correct multithreaded programs is tricky -- easier in Java than in some languages, but tricky anywhere. If you don't have a firm grasp of the language basics before you start in to work with threads then you are toast. Crispy brown toast. John Bollinger [EMAIL PROTECTED] ============================================================================== TOPIC: shallow copying an ArrayList in Java 5 http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9fd987b2d708a308 ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 11:26 am From: "Gary Newell" I need some help with Java 5. The code snippet below worked fine in Java 1.4.2. My code makes an array list of some predefined strings. The strings do not change, but the strings can belong (sometime concurrently) to various groups. In Java 1.4.2, I created the new group by copying an existing group and then modifying the group's contents. In Java 5, how do I "shallow copy" an ArrayList? code: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - import java.util.*; public class cloneArrayList { public static void main(String args[]) { ArrayList<String> original = new ArrayList<String>(); ArrayList<String> shallowCopy; // initialize the array list original.add( "StrA" ); original.add( "StrB" ); original.add( "StrC" ); // shallow copy the array list shallowCopy = (ArrayList) original.clone(); for( int j=0; j<original.size(); j++ ) { System.out.println( "j=" + j + ", str=" + shallowCopy.get( j ) ); } } } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Output: C:\temp>java cloneArrayList j=0, str=StrA j=1, str=StrB j=2, str=StrC - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Compiler warning: C:\temp>javac cloneArrayList.java Note: cloneArrayList.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C:\temp>javac -Xlint:unchecked cloneArrayList.java cloneArrayList.java:16: warning: [unchecked] unchecked conversion found : java.util.ArrayList required: java.util.ArrayList<java.lang.String> shallowCopy = (ArrayList) original.clone(); ^ 1 warning Without looping through each element, how do I shallow copy the original ArrayList? Thanks! Gary ============================================================================== TOPIC: File copy through RMI http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bd23301f7b38b8df ============================================================================== == 1 of 1 == Date: Mon, Dec 13 2004 10:42 am From: Sri Ramaswamy I need to perform a remote file copy on large files (15-20MB). I have a handle to a remote object which has access to inputStreams corresponding to these files. The code that exposes the the getInputStream() method is part of a 3rd party library and actually returns a ByteArrayInputStream. Since I cannot pass back the input stream through RMI, I am reading the input stream, creating an array of bytes, returning this byte array through RMI and writing these bytes to a file, on the other side. Here are the problems with this approach - 1) I am not sure how this library implements the getInputStream() method but the jvm crashes with a java.lang.OutOfMemoryError if the heap size is less than 64MB. 2) This process is very slow. If you have any thoughts/suggestions on a better approach that reduces the memory requirement and can speed up this operation, I would really appreciate it. Thank you, Sri Ramaswamy ============================================================================== You received this message because you are subscribed to the Google Groups "comp.lang.java.programmer" group. To post to this group, send email to [EMAIL PROTECTED] or visit http://groups-beta.google.com/group/comp.lang.java.programmer To unsubscribe from this group, send email to [EMAIL PROTECTED] To change the way you get mail from this group, visit: http://groups-beta.google.com/group/comp.lang.java.programmer/subscribe To report abuse, send email explaining the problem to [EMAIL PROTECTED] ============================================================================== Google Groups: http://groups-beta.google.com
