Simple Java Question - How to test if a given string is numeric or not
Hi Experts,
I have written one Java program. It fetches user ID from UME. The code is as below:
Iterator itr = role.getUserMembers(true);
while (itr.hasNext()) {
String uniqId = (String) itr.next();
IUser thisUser = myUserFactory.getUser(uniqId);
wdComponentAPI.getMessageManager().reportSuccess("here "+thisUser.getUid() );
Used ID is thisUser.getUid() . I have to find out all user IDs which are numeric.
Do we have any standard Java program (API) to find out whether thisUser.getUid() is numeric or not.
Regards,
Gary
Hi
Just try to parse this string to integer or long number and catch the NumberFormatException.
Somthing like:
try
Integer.parseInt(userIdString);
catch(NumberFormatException e)
//do sume thing when user id is not number
good luck
Similar Messages
-
Simple Java Question - How to Overwrite Set
After working so much in Java, wondering how do i overwrite java.util.Set
My pojo is Set of associated object. For example
class Parent
private Set child = new HashSet(0);
public Set getChild() {
return this.child;
I wanna overwrite set of child objects in pojo with the set passed from UI tier
Any pointers/suggestions will be highly appreciated
Regards
Bansipublic void setChild(Set child) { this.child = child; }or if you need more control over the Set instance:
public void setChild(Set child)
this.child.clear();
this.child.addAll(child);
} -
Simple/silly question: how do I set/change default font/color for outgoing mail messages?
Just a suggestion..........
Download Thunderbird. Easier to use when it comes to what you want to do w/your emails. -
May i know how to set the image .jpg or gif into the label ?
how to get the time in this format::Monday 12th Jan 2004
thanksHi,
If i want click the button then the image of the JLabel will be change.. how to write in syntax?
i know the c1 = new JLabel(new ImageIcon("sysImage/Send.gif"));
but i want another image after click command button.
is it c1.setImageIcon("abc.gif"); ? i try,but error..
how to apply the date fill into syntax? i not really know read the API
thanks -
Simple Query Question - How do I return the Last 3 records of a Table?
Question.
For example, I have a table that has 50 records.
How do I, specify in SQL to only return the last 3 records of the table.
Select a.* from table a where ????I was just trying to show an example to a friend on
how something like this would work and if it was even possible. But it won't work. Here's a simple example:
SQL> create table emp
2 (id)
3 as
4 select object_id
5 from all_objects
6 order by object_id;
Table created.
SQL> select *
2 from (select rownum rn
3 ,b.*
4 from emp b)
5 where rn > ( select (max(rownum) - 3)
6 from emp)
7 ;
RN ID
40830 55891
40831 55892
40832 55893So far, so good. These are the "last 3" rows inserted. Now delete a bunch of rows and insert 3 new ones:
SQL> delete emp where id < 40000;
33423 rows deleted.
SQL> commit;
Commit complete.
SQL> insert into emp values (60000);
1 row created.
SQL> insert into emp values (60001);
1 row created.
SQL> insert into emp values (60002);
1 row created.
SQL> commit;
Commit complete.
SQL> select *
2 from (select rownum rn
3 ,b.*
4 from emp b)
5 where rn > ( select (max(rownum) - 3)
6 from emp)
7 ;
RN ID
7410 55891
7411 55892
7412 55893Here's the problem. Even though the "last 3 rows" are 60000 - 60002, I still get the same ones as the first query. -
Simple java question, help please
please help
-i am just starting out in java and im havin an early problem. Im trying to run a small java script from a commant prompt but im getting the following error after i enter this command at my prompt
c:\javatest>javac HelloARP.java
javac is not as an internal or external command, operable program or batch file.
when i enter
c:\java -version
i get the following message: registry key software\javasoft\java runtime enviornment\current version has value of 1.1 but 1.4 is requiured
error: could not find java.dll
error: could not find java 2 runtime enviornment
-im sure this is a simple error on my part. all im trying to do is run my first lil program that i saved in notepad, its only 5 lines long. here is the lil test program im trying to execute
class HelloARP {
public static void main (String[] arguments) {
System.out.println("What's good ARP?");
- all responses and help are welcomed. Thank you ahead of time for anyone that can help me get started.Hi
First of all uninstall your current JDK installation, if you can get to the registry delete the registry entries for the old version of java which was there on your machine.
Now do a fresh install of your j2sdk1.4.1, make sure that you will install the JRE with the J2SDK1.4.1.
Once you are done, set your classpath in autoexec.bat if you are using Windows 95/98
or set your environment variables if you are using Win NT/2000/XP.
If using solaris or other unix flavors see the included installation instructions provided.
Let me if you face the same problem.
Thanks
Swaraj -
hey everyone!
im stuck, on the math part.
i need to add a formula to my applet, x = y*z, for example. For fixed values of y and z. So lets say y = 5 and z= 3. How do i get "15" to be displayed when an applet is started.
I have looked through java.math but did come across anything but complicated stuff.
your help is very appreciated.int y = 5, z = 3;
System.out.println(y*z); //prints out '15'This will be printed out to standard output (the shell), for an application.
I'm not sure how you want to print this using your applet.
But the main point is that simple maths can be done using operators on primitive data types (int, byte, short, double, long, ) Check out this important resource.
I recommend you read the whole tutorial, or at least the following sections:
Learning the Java Language
Writing Applets
Writing Swing Applets
regards,
lutha -
Issue 1:
if(totaliNumber < 1001) //Hello there, OR statements don't appear to work!
totaliNumber = 1001;
if(totaliNumber > 9999)
totaliNumber = 1001;
iNumber = totaliNumber;
++totaliNumber;This is only giving me the number 1001 each time it is called. if theres any other way to give me the next number other than keeping a count, let me know...
Issue 2:
public boolean exists(int nNumber)
//method
//some lines down
int temp = 0;
for(int i = 0; i < MAX_ENTRIES; i++)
temp = arrayOfMembers.getMemberNumber();
if(arrayOfMembers[i].exists(temp)); //cannot find symbol : method: exists(int) <--------------------------------------
return arrayOfMembers[i];
return null; //not found!Issue 3: How do I test a method that returns an array of integers? I want to print it out to see the results of the functiion. A simple print to the cmd box is fine i.e., System.out.print("");
full source code can be found here:
[http://docs.google.com/Doc?docid=0AXeIbNxo5as1ZGZkZnF3cmZfMzgxZ3E0cnRoZm0&hl=en|http://docs.google.com [/Doc?docid=0AXeIbNxo5as1ZGZkZnF3cmZfMzgxZ3E0cnRoZm0&hl=en] http://docs.google.com/Doc?docid=0AXeIbNxo5as1ZGZkZnF3cmZfMzgycDV3dmgyeDY&hl=en|/Doc?docid=0AXeIbNxo5as1ZGZkZnF3cmZfMzgxZ3E0cnRoZm0&hl=en] http://docs.google.com/Doc?docid=0AXeIbNxo5as1ZGZkZnF3cmZfMzgycDV3dmgyeDY&hl=en]
[http://docs.google.com/Doc?docid=0AXeIbNxo5as1ZGZkZnF3cmZfMzgzM2M3NjRyZG4&hl=en|http://docs.google.com/Doc?docid=0AXeIbNxo5as1ZGZkZnF3cmZfMzgzM2M3NjRyZG4&hl=en]if(totaliNumber < 1001) //Hello there, OR statements don't appear to work!
totaliNumber = 1001;
if(totaliNumber > 9999)
totaliNumber = 1001;
iNumber = totaliNumber;
++totaliNumber;This is part of a constructor and is supposed to generate a new number each time the constructor is used/called.
public boolean exists(int nNumber)
//method
//some lines down
int temp = 0;
for(int i = 0; i < MAX_ENTRIES; i++)
temp = arrayOfMembers.getMemberNumber();
if(arrayOfMembers[i].exists(temp)); //cannot find symbol : method: exists(int) <--------------------------------------
return arrayOfMembers[i];
return null; //not found!exists is a member function of arrayOfMembersarrayOfMembers = new Member[defaultnumberofmembers]; -
Hi!
Can someone tell me the answers of these questions, you can just bold the correct answer.Any help will be appreciated.
Thanks in advance.
Regards,
sandy.
1) Which of the following software components is not included in the standard Java SDK 2?
(a)appletviewer(b)JMF(c)Jar tool(d)Swing(e)none of the above
2) Which of the following is an abstract class in the Java API?
(a)int (b)Integer (c)WindowListener (d)WindowAdapter (e)none of the above
3) Which of the following types can be stored in a TreeMap?
(a)int (b)boolean (c)char (d)String (e)none of the above
4) How many main methods are allowed in a java program which comprises four user-defined classes?
(a)one (b)two (c)three (d)four (e)none of the above.
**********************************************************************about that main methods: i find it strange that only 1 main method is allowed, i would say: alot :)
Just to give an example of the possibilities:
public class Main {
public static void main (String[] args) {}
public static void main (int i) {}
public void main() {}
public void main (int i, String blah) {}
}All is allowed, only the
public static void main (String[] args) {}will be used as the startup method for the program.
So in other words, that question not complete.
Greets,
Barre -
A simple Java question...
How to wrap the text on the Button in Java?
For example, the text on the button is too long, I would like to switch it into two lines, but I don't know how to do it. Can anyone tell me how to do it?
Thank you very much!!!Someone told me about this....
after Java 1.1.7 and Swing 1.0.3, Swing do enable HTML rendering, so you can create a multiline button with the HTML code. eg.
JButton myButton = new JButton ("<html><center>Chevrolet<br>Light Truck</center></html>");
here have more 3 methods for create multiline button.
1. combination of JLabels and the JButton
JButton myButton = new JButton();
myButton.setLayout(new BorderLayout());
JLabel myLabel1 = new JLabel("Line1");
JLabel myLabel2 = new JLabel("Line2");
myButton.add(BorderLayout.NORTH,myLabel1);
myButton.add(BorderLayout.SOUTH,myLabel2);
2. create a new ButtonUI that formats your text properly
3. extend JButton and overriding paint method. tokenize string based on \n and recalculations spacing (no good)
Does it really work? -
Simple IPhoto Questions-How to reduce picture file size?
Hello,
I know how to reduce the size of photos using the Mail program, but is there a simple way to reduce the size of photo files and keep them for sending through the internet at later dates. I would like to keep the photos at their original size for viewing, but transfer photos to a file where they will be used to send over the net in much smaller format size.
thanksAs Larry says, you can resize the pics on Export using the File -> Export command.
and keep them for sending through the internet at later dates.
The intention in iPhoto is that you would only reduce the size on a case-by-case basis, rather than resize the whole library. As iPhoto always maintains the Originals this require quite a lot of disk space
Regards
TD -
Hi Experts,
I am getting following run time error message while running a Web Dynpro program:
java.lang.ClassCastException: com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCException: List must contain AbstractList (ProxyList) of Type 'com.sasol.pr.create.Bapimereqitemimp$Bapimereqitemimp_List', not of 'class com.sasol.pr.create.Bapimereqitem$Bapimereqitem_List'!
Detailed error message is:
Web Dynpro Client Type HTML Client
User agent Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; InfoPath.1)
Version null
DOM version null
Client Type msie6
Client Type Profile ie6
ActiveX enabled
Cookies enabled
Frames enabled
Java Applets enabled
JavaScript enabled
Tables enabled
VB Script enabled
Server
Web Dynpro Runtime Vendor: SAP, build ID: 7.0011.20070125102926.0000 (release=645_VAL_REL, buildtime=2007-01-31:20:18:32[UTC], changelist=434634, host=pwdfm101), build date: Thu Apr 12 16:35:25 IST 2007
J2EE Engine No information available
Java VM Java HotSpot(TM) 64-Bit Server VM, version:1.4.2 1.4.2.12-061213-10:06-IA64W IA64W, vendor: Hewlett-Packard Company
Operating system HP-UX, version: B.11.23, architecture: IA64W
Session & Other
Session Locale en_US
Time of Failure Tue Apr 17 14:05:49 IST 2007 (Java Time: 1176798949444)
Web Dynpro Code Generation Infos
local/Pr_Create_16042007_I
SapDictionaryGenerationCore 6.4009.00.0000.20041026131628.0000 (release=630_REL, buildtime=2004-11-02:22:13:11[UTC], changelist=295793, host=PWDFM027.wdf.sap.corp)
SapDictionaryGenerationTemplates (unknown)
SapGenerationFrameworkCore 6.4009.00.0000.20041026132141.0000 (release=630_REL, buildtime=2004-11-02:22:05:28[UTC], changelist=295805, host=PWDFM027.wdf.sap.corp)
SapIdeWebDynproCheckLayer 6.4009.00.0000.20041026133106.0000 (release=630_REL, buildtime=2004-11-02:22:21:59[UTC], changelist=295820, host=PWDFM027.wdf.sap.corp)
SapMetamodelCommon 6.4009.00.0000.20040909194107.0000 (release=630_REL, buildtime=2004-11-02:22:06:42[UTC], changelist=280398, host=PWDFM027.wdf.sap.corp)
SapMetamodelCore 6.4009.00.0000.20040909194107.0000 (release=630_REL, buildtime=2004-11-02:22:06:29[UTC], changelist=280398, host=PWDFM027.wdf.sap.corp)
SapMetamodelDictionary 6.4009.00.0000.20040805191532.0000 (release=630_REL, buildtime=2004-11-02:22:10:20[UTC], changelist=270520, host=PWDFM027.wdf.sap.corp)
SapMetamodelWebDynpro 6.4009.00.0000.20041026132448.0000 (release=630_REL, buildtime=2004-11-02:22:17:25[UTC], changelist=295810, host=PWDFM027.wdf.sap.corp)
SapWebDynproGenerationCTemplates 6.4009.00.0000.20041102105304.0000 (release=630_REL, buildtime=2004-11-02:22:38:28[UTC], changelist=297524, host=PWDFM027)
SapWebDynproGenerationCore 6.4009.00.0000.20041026133106.0000 (release=630_REL, buildtime=2004-11-02:22:22:31[UTC], changelist=295820, host=PWDFM027.wdf.sap.corp)
SapWebDynproGenerationTemplates 6.4009.00.0000.20041102105304.0000 (release=630_REL, buildtime=2004-11-02:22:38:28[UTC], changelist=297524, host=PWDFM027)
sap.com/tcwddispwda
No information available null
sap.com/tcwdcorecomp
No information available null
Detailed Error Information
Detailed Exception Chain
java.lang.ClassCastException: com.sap.tc.webdynpro.modelimpl.dynamicrfc.WDDynamicRFCException: List must contain AbstractList (ProxyList) of Type 'com.sasol.pr.create.Bapimereqitemimp$Bapimereqitemimp_List', not of 'class com.sasol.pr.create.Bapimereqitem$Bapimereqitem_List'!
at com.sap.tc.webdynpro.modelimpl.dynamicrfc.DynamicRFCModelClass.setRelatedModelObjects(DynamicRFCModelClass.java:807)
at com.sasol.pr.create.Bapi_Pr_Create_Input.setPritem(Bapi_Pr_Create_Input.java:403)
at com.sasol.pr.creation.PrCreationCust.executeBapi_Pr_Create(PrCreationCust.java:215)
at com.sasol.pr.creation.wdp.InternalPrCreationCust.executeBapi_Pr_Create(InternalPrCreationCust.java:240)
at com.sasol.pr.creation.ApplView.onActionSearch(ApplView.java:152)
at com.sasol.pr.creation.wdp.InternalApplView.wdInvokeEventHandler(InternalApplView.java:258)
at com.sap.tc.webdynpro.progmodel.generation.DelegatingView.invokeEventHandler(DelegatingView.java:87)
at com.sap.tc.webdynpro.progmodel.controller.Action.fire(Action.java:67)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.doHandleActionEvent(WindowPhaseModel.java:420)
at com.sap.tc.webdynpro.clientserver.window.WindowPhaseModel.processRequest(WindowPhaseModel.java:132)
at com.sap.tc.webdynpro.clientserver.window.WebDynproWindow.processRequest(WebDynproWindow.java:335)
at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:143)
at com.sap.tc.webdynpro.clientserver.session.ApplicationSession.doProcessing(ApplicationSession.java:299)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessingStandalone(ClientSession.java:759)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doApplicationProcessing(ClientSession.java:712)
at com.sap.tc.webdynpro.clientserver.session.ClientSession.doProcessing(ClientSession.java:261)
at com.sap.tc.webdynpro.clientserver.session.RequestManager.doProcessing(RequestManager.java:149)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:62)
at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:53)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:387)
at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:365)
at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:944)
at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:266)
at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:160)
at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
at java.security.AccessController.doPrivileged(Native Method)
at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
Can you please have a look on it and suggest me the solution.
Regards,
RKHi Ravinda,
You add to one of your WD RFC Adaptive model relations not instance of com.sasol.pr.create.Bapimereqitemimp$Bapimereqitemimp_List BUT com.sasol.pr.create.Bapimereqitem$Bapimereqitem_List
Check the place where you instanciate your model, establish relations and bind model to model class.
Best regards, Maksim Rashchynski. -
Simple Java Question vs. Visual Basic 6
What are the core advantages in using Jbuilder9?
What are the disadvantages of using Jbuilder9?
And what advantages does Jbuilder have over VB6?
And What is UI? And IDE????I think you first need to ask yourself wether Java or
Microsoft is the way to go. Java is portable and secure
(among other things).
If you are looking for graphical tools to build web
applications, you may want to consider Java Studio
Creator, which will be available in Early Access in a
few weeks time:
http://wwws.sun.com/software/products/jscreator/index.html
hth,
Alexis -
Simple Java Question (Hopefully)
I'm not sure if anyone out here is familiar with ClearCase, I'm sure there are some, but I am trying to create some basic classes that perform various cleartool shell out commands, one of which returns the some information about ClearCase code repositories.
When I execute a command line "cleartool lsvob" via cmd here's what I get:
\mt_group \\happy\vobdata\vobstore\mt_group.vbs public
* \company_cmtools \\happy\vobdata\vobstore\company_cmtools.vbs public
\loc_test \\happy\vobdata\vobstore\loc_test.vbs public
\iais \\happy\vobdata\vobstore\iais.vbs public
\loc_test1 \\happy\vobdata\vobstore\loc_test1.vbs public
* \ccase_tool \\happy\vobdata\vobstore\ccase_tool.vbs public
\ddts \\happy\vobdata\vobstore\ddts.vbs public
\cmtools_a2 \\happy\vobdata\vobstore\cmtools_a2.vbs public
\pams \\happy\vobdata\vobstore\pams.vbs public
However, when I try to do this via a class file it just sits there and doesn't do anything. When I change the command string to "cleartool lsvob -s" it prints:
\mt_group
\company_cmtools
\loc_test
\iais
\loc_test1
\ccase_tool
\ddts
\cmtools_a2
\pams
Does Java have a problem with white spaces? Here is the code I have:
import java.lang.*;
import java.io.*;
import com.oroinc.text.perl.*;
public class GetVobMount {
String cleartool;
String os = System.getProperty("os.name");
String cmd = " lsvob";
public String getVobs () {
Perl5Util perl = new Perl5Util();
if (perl.match("/Win/i", os)) {
cleartool = "cmd /c cleartool.exe";
} else {
cleartool = "/usr/atria/bin/cleartool";
StringBuffer data = new StringBuffer();
System.out.println(cleartool + cmd);
try {
Runtime r = Runtime.getRuntime();
Process p = r.exec(cleartool + cmd);
p.waitFor();
DataInputStream in = new DataInputStream(p.getInputStream());
String input;
while ((input = in.readLine()) != null) {
data.append(input);
data.append("\n");
} catch (Exception e) { System.out.println(e); }
return data.toString();
public static void main (String [] args) {
GetVobMount vobs = new GetVobMount();
System.out.println(vobs.getVobs());
}Of course this won't work in an enviroment that isn't using ClearCase but perhaps there is a reason why java won't return a string of:
\something \\server\path\dir\something.vbs public
Any help or suggestions will be greatly appreciated.
-WesHowdy... I myself have done a lot of clearcase work with a Java app that runs on both UNIX and NT, so hail to you.
So the problem here is that the spawned process blocks? And there is no way to get it to resume?? Isn't this a bug?? The original code seems perfectly acceptable.
I've encountered the same problem. My app. was running some system calls and there were some unusual error messages due to system/server problems. The java app should've handled it fine (I handle STDERR), but instead my java app FROZE, no doubt because the spawned process went into this blocked state as Chuck described. In my case, when the system/server error was fixed and the error messages went away, my app stopped locking up. -
Simple audio question - how to mute a track?
Have a timeline with one video and two audio tracks - both tracks are stereo.
I need to mute one of the audio tracks to make edits to the other.
How can I mute one of the audio tracks?Awesome - that's what I was looking for! Ton of clips so hitting shift-Z and then selecting the entire length of the track seems to work.
Where is that "V" feature in the menus?
Maybe you are looking for
-
Code not working in service mode
============= Dim regKey As RegistryKey Try regKey = Registry.CurrentUser.CreateSubKey("Software\ADOBE\Acrobat Distiller\PrinterJobControl") regKey.SetValue(objPptApp.Path & "\POWERPNT.EXE", strFileOutput, RegistryValueKind.String) regKey.Flush() reg
-
Windows 7 64-bit and Quicktime - stamp sized image of player
I have Windows 7 64-bit and downloaded the latest iTunes/Quicktime program. iTunes works fine. When I open Quicktime, the logo appears in the tray, indicating it is open. However, nothing opens up on the screen. When my mouse hovers above the "Q"
-
My Select Buttin Doesn't Work on Clickwheel
I have an older ipod 20 gb. I dont know what generation. I've downloaded updated software , and have attempted to do reset. Problem is the clickwheel works - all buttons - play/pause, menu/baclight, forward, reverse, but the select button does NOT. S
-
I am not able to open a batch input job using SM37
Hi Gurus, I am not able to open a batch input job using SM37. I enter SM37 through a well authorized ID. May be there is a authorization issue or may be not. I check all the check boxes even then it is not possible. Please help
-
ProcessConnect - Oracle DB Delivery Channel error
I'm trying to create a delivery channel for Oracle DB Adapter. I'm getting following error: Error - Unhandled Exception System Error : java.lang.NoClassDefFoundError I found more information in <oraclehome>/ip/log/ui/log.xml: <MESSAGE> <HEADER> <TSTZ