comp.lang.java.programmer http://groups-beta.google.com/group/comp.lang.java.programmer [EMAIL PROTECTED]
Today's topics: * Java regexp help - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/be3143a676a4bc8f * where is the source code....??? ...am I ever confused....!! - 3 messages, 3 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cac9bb6510a8bd63 * Locale question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/54f1e8452a7c830 * TOMCAT/MYSQL/JSP - 2 messages, 2 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6cfdfa12d76632b1 * Looking for simple rectangle drawing source code - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d60e3ea701323ebb * Threadsafe Timers? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/84b90615248a59bc * static function to change Component properties application-wide - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3680a54fa0625336 * How to retrive the folder structure on the server and display on an applet on the client side. - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/16797f8b3442128b * Java simulator - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d3534ac941fb264f * bit manuplation - 4 messages, 4 authors http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bffe2f28401cd27f * Parsing a Schema to build a JTree - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4522b0f7e93fb2de * db connections - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9796781dceede8f6 * Singleton or static class? - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c6605e437a9085c2 * Commons logging question - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/148ce5bb9c7abd0c * UnsatisfiedLinkError in Eclipse standalone SWT app - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e03dc0d087a5062a * How to change 3 to "003" - 1 messages, 1 author http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4f04fef73a25ccc0 ============================================================================== TOPIC: Java regexp help http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/be3143a676a4bc8f ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 8:27 am From: "pet0etie" i don't know if i get the question right but this might be my solution : import java.util.regex.*; public class Value { public static void main(String[] args) { String[] lines = new String[] { "$.50.","$0.50.","$6.25.","$12.30.","$6.25","$0.50","2350.","10.","$23a.4."} ; String regexp = "^\\$?(\\d*\\.?\\d*)\\.?"; Pattern pattern = Pattern.compile(regexp); for (int i = 0; i < lines.length; i++) { System.out.println("Does text " + lines[i] + " match regexp? " + lines[i].matches(regexp)); if (lines[i].matches(regexp)) { Matcher matcher = pattern.matcher(lines[i]); while (matcher.find()) { System.out.println(" " + lines[i] + " matches " + regexp + " with " + matcher.group() + " Start <" + matcher.start() + ">, End <" + matcher.end() + ">."); // start modification // int start = matcher.start() + ((lines[i].charAt(matcher.start()) == '$') ? 1 : 0); int end = matcher.end() - ((lines[i].charAt(matcher.end()-1) == '.') ? 1 : 0); System.out.println(" The extracted value = " + lines[i].substring(start,end)); // end modification // } } } } } greetz, pet0etie ============================================================================== TOPIC: where is the source code....??? ...am I ever confused....!! http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/cac9bb6510a8bd63 ============================================================================== == 1 of 3 == Date: Sat, Dec 18 2004 2:34 am From: "David" Hi I've been bouncing back and forth between languages, and just when I think I might like Java after all, I run into one of these things again..... I don't know why I want to do this, but..... I'm trying to determine exactly where the code comes from when you implement the Toolkit.getDefaultToolkit() method. For example, I want to see the implementation of Toolkit.getDefaultToolkit().getImage(String filename) .... (I figure there must be a pile of interesting code in that one). In the source for Toolkit, the getDefaultToolkit() method returns another Toolkit. It seems to use a series of conditions to 'apply' a system specific class to the returned Toolkit, which I assume then makes it all act like a 'real' class (instead of a set of abstract methods). I am getting the creepy feeling that some of the system specific concrete class implementations might only be included as compiled .class files, and the actual source code is not available or something. A search for "getImage(String filename)" in an unzipped scr.jar file directory produced no results, other than the single abstract method in Toolkit. Nor did a search of the text in the entire JDK directory. This leads me to believe it's just not there (unless I have to try every combination of space char's and stuff..) My question is, does anybody know where this source code is hiding. If this has been answered recently, please just point me in the right direction. I didn't know I was going to want to know this before so I wasn't looking then to see if somebody else was going to ask about it...... .....and now be damned if I can find it anywhere..... Thanks if you can help! David Otte == 2 of 3 == Date: Sat, Dec 18 2004 11:00 am From: "Andrei Kouznetsov" > I've been bouncing back and forth between languages, > and just when I think I might like Java after all, I run into > one of these things again..... > > I don't know why I want to do this, but..... > I'm trying to determine exactly where the code comes > from when you implement the Toolkit.getDefaultToolkit() > method. try this: System.out.println(Toolkit.getDefaultToolkit().getClass().getName()); then you know where to search. if it starts with "sun." then no source code is available. -- Andrei Kouznetsov http://uio.dev.java.net Unified I/O for Java http://reader.imagero.com Java image reader http://jgui.imagero.com Java GUI components and utilities == 3 of 3 == Date: Sat, Dec 18 2004 8:11 am From: "Ryan Stewart" "Andrei Kouznetsov" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] >> I've been bouncing back and forth between languages, >> and just when I think I might like Java after all, I run into >> one of these things again..... >> >> I don't know why I want to do this, but..... >> I'm trying to determine exactly where the code comes >> from when you implement the Toolkit.getDefaultToolkit() >> method. > > try this: > > System.out.println(Toolkit.getDefaultToolkit().getClass().getName()); > > then you know where to search. > if it starts with "sun." then no source code is available. > Not strictly true: http://www.cs.duke.edu/csed/java/src1.3/sun/awt/SunToolkit.java That's an older version, but you might find something more up to date if you look around. ============================================================================== TOPIC: Locale question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/54f1e8452a7c830 ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 10:37 am From: Stephen Riehm hilz wrote: > Hi all > > I have couple of files: > file_en.txt > file_fr.txt > file_es.txt > file_de.txt > > they contain the same simple text in their corresponding languages. > and i want to be able to load these files according to the locale. > > I know that: > ResourceBundle.getBundle("file", Locale Locale) > should be used if those files were ".properties" files and contained > key=value pairs. But my files contain just simple text. Is there an > equivalent way of getting the text from those files in a single call similar > to ResourceBundle.getBundle(String baseName, Locale locale) .properties files are also just text files, with minimal formatting. If you know what's right, why don't you make your locale files 'right' and then use the normsl, right way. The person who has to maintain your code will thank you :-) I normally have a locale/ directory in my jar file, and then put the translations in files like messages_en.properties, messages_de.properties, etc. Just like they tell you in the books ;-) It works great. PS: a simple one-line perl or sed command can be used to convert many simple text formats into other formats... ie: if your texts are tab seperated, you could use the following to turn them into key = values pairs. perl -pe 's/\t/=/' file_en.txt > messages_en.properties cheers, Steve ============================================================================== TOPIC: TOMCAT/MYSQL/JSP http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/6cfdfa12d76632b1 ============================================================================== == 1 of 2 == Date: Sat, Dec 18 2004 1:37 am From: "atishay kumar" are you able to access the database using the mysql client. you will find a exe as mysql in bin directory of your mysql installation directory. are you able to login using that... i recently used some other jar for conencting to the mysql db on windows. i can send you that jar find and relevant jsp portion of the code.... cheers atishay == 2 of 2 == Date: Sat, Dec 18 2004 7:58 am From: "Ryan Stewart" "Kevin Robinson" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > The error message that I obtain fron the Tomcat command window is as > follows: > > java.sql.SQLException: Communication failure during handshake. Is there a > server running on localhost:3306? > at org.gjt.mm,mysql.MysqlIO.init(Unknown Source) > at org.gjt.mm,mysql.Connection.connectionInit(Unkown Source) > at org.gjt.mm,mysql.jdbc2.Connection.connectionInit(Unkown Source) > at org.gjt.mm,mysql.Driver.connect(Unkown Source) > at java,sql.DriverManager.getConnection(DriverManager.java:512) > at java,sql.DriverManager.getConnection(DriverManager.java:193) > > There is more stuff after this. > To me it looks as if it cant find the database on port 3306 but the > database > is up and running as I can acces it > with mysql administrator and SQLyog on prt 3306. > > The OS is XP home edition and the database server starts up automatically. > Try restarting your MySQL server if you haven't already. Try upgrading to the latest driver version. Have a look at some MySQL documentation for version 4.1 and/or later. Looking around the net, I've seen mention of MySQL changing its password storage format and something about an "--old-passwords" switch and OLD_PASSWORD() function. ============================================================================== TOPIC: Looking for simple rectangle drawing source code http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d60e3ea701323ebb ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 11:06 am From: "Andrei Kouznetsov" >I need to write a very simple "visual" widget drawing application. > > The app user will select an item from a palette and then > by click and drag, create a rectangle. > > This must be the most common (after a simple click) operation > in all the GUI environments. > > Anyway, I am looking for the code that implements the > reactangle drawing/erasing as the mouse is dragged around. > Any pointers?? it is very easy... while mouse dragging you make following: first getGraphics from your Component or Canvas or whatever. then you set XOR painting mode on that Graphics then if there exist saved(!) rectangle you draw it. then you draw current rectangle. then you save your current rectangle. and dispose Graphics thats it! -- Andrei Kouznetsov http://uio.dev.java.net Unified I/O for Java http://reader.imagero.com Java image reader http://jgui.imagero.com Java GUI components and utilities ============================================================================== TOPIC: Threadsafe Timers? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/84b90615248a59bc ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 11:16 am From: "Filip Larsen" Will wrote > I have recently begun the joys of ensuring that all of my GUI/Swing > code is thread safe by adding invokeLater() and invokeAndWait() methods > everywhere. As far as I can tell, all Swing classes are assumed to NOT > be thread safe. Does this include javax.swing.Timer? Specifically, I > use Timers all over the place for regularly scheduled tasks and when I > turn them on or off, or restart() them, do these also need to be > enclosed in invokeLater() and invokeAndWait() methods? Is it safe to > assume that the event handlers for Timers execute on the event > dispatching thread so that anything within these tasks is safe without > the extra protection? In case it matters my target JVM is the 1.3.1_07 > JRE from Sun. Thanks for any help! Even though you use 1.3 you might find the documentation for the 1.4 javax.swing.Timer a bit more helpful. Let me quote from http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/Timer.html: "Although all Timers perform their waiting using a single, shared thread (created by the first Timer object that executes), the action event handlers for Timers execute on another thread -- the event-dispatching thread. This means that the action handlers for Timers can safely perform operations on Swing components. However, it also means that the handlers must execute quickly to keep the GUI responsive." "In v 1.3, another Timer class was added to the Java platform: java.util.Timer. Both it and javax.swing.Timer provide the same basic functionality, but java.util.Timer is more general and has more features. The javax.swing.Timer has two features that can make it a little easier to use with GUIs. First, its event handling metaphor is familiar to GUI programmers and can make dealing with the event-dispatching thread a bit simpler. Second, its automatic thread sharing means that you don't have to take special steps to avoid spawning too many threads. Instead, your timer uses the same thread used to make cursors blink, tool tips appear, and so on." -- End of quote. Regards, -- Filip Larsen ============================================================================== TOPIC: static function to change Component properties application-wide http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/3680a54fa0625336 ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 3:13 am From: "Gert" That's the one thanks! ============================================================================== TOPIC: How to retrive the folder structure on the server and display on an applet on the client side. http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/16797f8b3442128b ============================================================================== == 1 of 4 == Date: Sat, Dec 18 2004 3:58 am From: "bala" I have to retrieve the directory structure on the server and display it to the user. Once the user selects a folder from the tree, the files have to load on a different pane. Of course the folder structure could change on the server if any folder or file is added. In short, i have to get something like the windows file explorer. Is it possible to do this with applet alone or use servlets. If we can do this using servlets, how can i retrieve the folder structure and send it to the applet which will be the user interface? == 2 of 4 == Date: Sat, Dec 18 2004 12:40 pm From: "Dag Sunde" "bala" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > I have to retrieve the directory structure on the server and display it > to the user. Once the user selects a folder from the tree, the files > have to load on a different pane. Of course the folder structure could > change on the server if any folder or file is added. In short, i have > to get something like the windows file explorer. Is it possible to do > this with applet alone or use servlets. If we can do this using > servlets, how can i retrieve the folder structure and send it to the > applet which will be the user interface? * A servlet on the server that takes a root-foldername as input, scans, and build a (ie. xml) string representing the folder-structure. * In the Applet, a method that executes an HTTP POST to the servlet. When the returned string response are available, parse it, and build a three in the applet. Of course, this will be "pull", and will not automatically detect changes in the servers forlder-structure. -- Dag. == 3 of 4 == Date: Sat, Dec 18 2004 12:58 pm From: "Big Jim" "Dag Sunde" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > "bala" <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > I have to retrieve the directory structure on the server and display it > > to the user. Once the user selects a folder from the tree, the files > > have to load on a different pane. Of course the folder structure could > > change on the server if any folder or file is added. In short, i have > > to get something like the windows file explorer. Is it possible to do > > this with applet alone or use servlets. If we can do this using > > servlets, how can i retrieve the folder structure and send it to the > > applet which will be the user interface? > > * A servlet on the server that takes a root-foldername as input, scans, > and build a (ie. xml) string representing the folder-structure. > * In the Applet, a method that executes an HTTP POST to the servlet. > When the returned string response are available, parse it, and > build a three in the applet. > > Of course, this will be "pull", and will not automatically detect > changes in the servers forlder-structure. > > -- > Dag. > Would it be possible in this case to allow the applet to "register" itself with the server and provide an update method that the server will call via rmi when it's updated as in the Observer patteren? I'm wondering if this is possible with respect to security restrictions? == 4 of 4 == Date: Sat, Dec 18 2004 2:52 pm From: Stefan Schulz On Sat, 18 Dec 2004 12:58:29 GMT "Big Jim" <[EMAIL PROTECTED]> wrote: > Would it be possible in this case to allow the applet to "register" > itself with the server and provide an update method that the server > will call via rmi when it's updated as in the Observer patteren? I'm > wondering if this is possible with respect to security restrictions? I am not sure about the RMI part, but in principle it is possible. If RMI is not available, just use another protocol. -- In pioneer days they used oxen for heavy pulling, and when one ox couldn't budge a log, they didn't try to grow a larger ox. We shouldn't be trying for bigger computers, but for more systems of computers. --- Rear Admiral Grace Murray Hopper ============================================================================== TOPIC: Java simulator http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/d3534ac941fb264f ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 1:06 pm From: "djaksic" Hi, does anyone know where I can fid source for something like java proxy simulator?I'm building my own so any help is welcome. THANX! ============================================================================== TOPIC: bit manuplation http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/bffe2f28401cd27f ============================================================================== == 1 of 4 == Date: Sat, Dec 18 2004 4:26 am From: [EMAIL PROTECTED] well hi ther i have alittle advanced question about bitmanuplation if i have a set of bits such as 10110011 which can be any thing arrays of 1 and 0 or may be string or mostly BitSet is there is away to convert it to byte or may be to any other premitive type such as int or char with the rest of the bits be zeros ??!! hope i will find an answer to my question == 2 of 4 == Date: Sat, Dec 18 2004 5:52 am From: [EMAIL PROTECTED] Try the wrapper class Integer == 3 of 4 == Date: Sat, Dec 18 2004 8:02 am From: "Ryan Stewart" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Try the wrapper class Integer > Or Byte or Short or Long. Specifically, the T.parseT() methods, where T is one of the aforementioned types. == 4 of 4 == Date: Sat, Dec 18 2004 7:39 am From: Chris Smith <[EMAIL PROTECTED]> wrote: > well hi ther i have alittle advanced question about bitmanuplation > > if i have a set of bits such as 10110011 > > which can be any thing arrays of 1 and 0 or may be string or mostly > BitSet You've got answers for String. As for BitSet, the following should work: public int bitsetToInt(BitSet bitset) { if (bitset.length() > 32) throw new IllegalArgumentException(); int result = 0; for (int i = 0; i < 32; i++) { if (bitset.get(i)) result |= (1 << i); } return result; } Of course, this code will fail if there are more than 32 bits in the BitSet. You can modify the above as appropriate for byte, short, or long if you prefer. It makes no sense to put a bit mask in char, but if you really wish to do so, then the same code will work. -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation ============================================================================== TOPIC: Parsing a Schema to build a JTree http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4522b0f7e93fb2de ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 4:46 am From: [EMAIL PROTECTED] Wow, cheers. I think I have a reasonably good idea of what needs doing now and will probably get on to doing some more later on today. Thanks alot Chris and I'll probably get back to you again. ============================================================================== TOPIC: db connections http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/9796781dceede8f6 ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 12:53 pm From: "Big Jim" Thanks guys, I'll do some testing with the close to see if I get any resource problems and if I still do I'll resort to that most dreaded of programmer tactis, RTFM! "Sudsy" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Ryan Stewart wrote: > > "Sudsy" <[EMAIL PROTECTED]> wrote in message > > news:[EMAIL PROTECTED] > > > >>Big Jim wrote: > >> > >>>Guys, > >>> > >>>In a a stateful session bean I'm looking up a data source that wraps a > >>>connection pool and using it to retrieve a connection. > >>>How do I return the connection to the pool when I'm done? Is conn.close() > >>>the right thing to do here? > >> > >>Absoutely right! Closing it releases it back to the pool. > >> > > > > Are you sure that's universal? I may be wrong, but I thought I'd read about > > pooling implementations in which you'd call something like > > connection.release() or even ConnectionPool.dump(connection) > > A quick trip to the javadocs finds this in javax.sql.PooledConnection: > > "When an application closes a connection, it calls the Connection > method close. When connection pooling is being done, the connection > pool manager is notified because it has registered itself as a > ConnectionEventListener object using the ConnectionPool method > addConnectionEventListener. The connection pool manager deactivates > the handle to the PooledConnection object and returns the > PooledConnection object to the pool of connections so that it can > be used again. Thus, when an application closes its connection, > the underlying physical connection is recycled rather than being > closed." > > Do all implementations faithfully implement this? Possibly not, if > you've heard about situations where non-standard methods are > required. This is just the way it's /supposed/ to work. > Fair enough? ============================================================================== TOPIC: Singleton or static class? http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/c6605e437a9085c2 ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 3:03 pm From: Chris Berg On Fri, 17 Dec 2004 14:51:17 +0100, Stefan Schulz <[EMAIL PROTECTED]> wrote: >(Cause a class >load in a static initializer, and you'll be suprised!) What do you mean by that? Do you mean a new class referenced for the first time (and thus class-loaded) inside a static{..} block? Why is that a problem? Chris ============================================================================== TOPIC: Commons logging question http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/148ce5bb9c7abd0c ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 8:18 am From: "Ryan Stewart" "JamesZ" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Sometimes I find that the change I made on one log4j.properties file > didnt take effective. Maybe there is another log4j.properties file that > takes precedence over the file I changed. If the classpath is very > long, It is a pain for me to find out which particular property file is > picked at runtime. > I wonder if there is a way to print out the exact location of a given > resouce file. > By using the following method, I can get the exact location of a class > file loaded by the Class Loader: > Class a = AObject.getClass(); > String location = > a.getProtectionDomain().getCodeSource().getLocation(); > System.out.println("location of class = " + location); > But the above wont work for a resouce file. > Are we talking about a web application or a standalone application? If the former, log4j.properties needs to be in WEB-INF/classes. Otherwise control your classpath better. It can't be that difficult to figure out which file is being used. ============================================================================== TOPIC: UnsatisfiedLinkError in Eclipse standalone SWT app http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/e03dc0d087a5062a ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 7:20 am From: [EMAIL PROTECTED] Make sure the dll is in your PATH, if it doesn't help to add it to your PATH variable, copy-paste it to your system C:\WINDOWS directory. remko caprio http://www.szirine.com Henry Law wrote: > Eclipse 3.0.0 under Windows XP. > > I have (as far as I can see) followed the instructions in the cheat > sheet for "Standalone SWT Application" but I have the following error > on running it: > > java.lang.UnsatisfiedLinkError: no swt-win32-3062 in > java.library.path > > I have coded > > -Djava.library.path=${system:ECLIPSE_HOME}/plugins/org.eclipse.swt.${system:WS}_3.0.0/os/${system:OS}/${system:ARCH} > > in the "arguments" box (and various other variants of it including > hard path names), and verified that > > C:\USR\eclipse\plugins\org.eclipse.swt.win32_3.0.0\os\win32\x86\swt-win32-3062.dll > > does actually exist in my system. I've also set ECLIPSE_HOME as an > environment variable (just in case), without improving things. > > I've also Googled for the error and found only the advice to put in > the -D parameter, but I have done that already. Can someone suggest > somewhere else I might look for an error? > > -- > > Henry Law <>< Manchester, England ============================================================================== TOPIC: How to change 3 to "003" http://groups-beta.google.com/group/comp.lang.java.programmer/browse_thread/thread/4f04fef73a25ccc0 ============================================================================== == 1 of 1 == Date: Sat, Dec 18 2004 7:42 am From: Chris Smith pet0etie <[EMAIL PROTECTED]> wrote: > private DecimalFormat createFormat(int numDigits){ > // Create a String that is all 0's, and the length is numDigits. > StringBuffer zeros = new StringBuffer(); > for (int digit = 1; digit <= numDigits; digit++) { > zeros.append("0"); > } > // Now use that to create a DecimalFormat object. > return new DecimalFormat(zeros); > } It may be easier to do it this way: NumberFormat format = NumberFormat.getInstance(); format.setMinimumIntegerDigits(numDigits); -- www.designacourse.com The Easiest Way To Train Anyone... Anywhere. Chris Smith - Lead Software Developer/Technical Trainer MindIQ Corporation ============================================================================== 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
