SIMPLE QUESTION! converting an Enumeration to a String array;

Enumeration e=request.getParameterNames();
i have an enumeration that contains some String objects
how can i convert it to a String array?
thanks a lot.

String str = null;
List list = new ArrayList();
while(e.hasMoreElements()) {
     str = (String)e.nextElement();
     list.add(str);
String[] strArray = (String[]) list.toArray();
Disclaimer: Code not tested; use at your own
risk ;)Taht piece of code will probably throw class cast exception at the line:
String[] strArray = (String[]) list.toArray();The array returned is an object array. You should use:
String[] strArray = (String[]) list.toArray(new String[list.size()]);That methods returns an array of the same type as the argument.
/Kaj

Similar Messages

  • How to convert String array into int.

    void getSoldSms(Vector vecSoldSms)
         String str[]=new String[vecSoldSms.size()];
         String words[]=new String[str.length]; // String array
              for(int i=0;i< vecSoldSms.size();i++)
                   str=(String)vecSoldSms.get(i);
              }               //End for
              for(int i=0;i<str.length;i++)
              words = str[i].split("\\|\\|");
              System.out.println();
              for(int j=0;j<1;j++)     
              int count[str.length]=Integer.parseInt(words[i]);
              System.out.print(count[j]*advance_count);
              } // end inner for loop
              }          //End for
         }          //End function getSoldSms
    how do i convert words which is a string array into int type. i kno string can be converted into int using interger.parseint. but wat abt string arrays??? plz help me out with the above code.

    i did tht its still giving the same errorFor Heaven's sake, what about taking a second to try to understand the code you're copying first? If you really can't fix the error yourself, you have a more serious problem than just convertingStrings to ints.
    And if you want { "1", "2", "3" } to be 123:
    StringBuffer b = new StringBuffer();
    for (int i = 0; i < array.length; i++) {
      b.append(array);
    int result = Integer.parseIn(b.toString());

  • Vector to String Array

    Hello all...
    How can i convert a vector to a string array?

    If it's inserted into the vector as a String, then the toArray() method is exactly what you want. Otherwise, a simple for loop doing a "array[i] = thing.toString()" bit ought to do nicely.

  • Pro Tools convert to Logic Newbie some simple question for logic users

    Hey guys, I am a recent convert from Pro Tools! and There were just some simple questions I thought some of you may be able to help me out with. I am using Logic 9.1.1
    1) After I set up a multi timbral software instrument (in this case MOTU Symphonic Library) how do I set up midi channels to trigger the individual sounds in the instrument. (in pro tools I used to create a midi track then send an output of that track to that particular soft synth)
    2) How do I set up a and forgive my Pro Tools vocab but basically I want to set up a reverb channel on an aux track have it receive on a bus so I can send other tracks to that particular bus.
    Thanks for the insight and really looking forward to finally make use of all this ram! lol

    1) I have a nord stage and would like record via midi. In pro tools i would usually need to create a midi track with the output set the the nord and an audo aux track to hear it What would I do in order to record midi from my nord stage?
    To record, just select a non-audio track, hit record and play the keyboard. The notes will get recorded into a region.
    If you want to play it back to the Nord Stage as well, then it makes sense to set the Nord up as a MIDI device in your templates, so you can just add the Nord to a track and not worry about what MIDI ports it's on etc. Open the environment, create a New -> Instrument, called it "Nord Stage", set the MIDI port and MIDI channels it's on, and sav your template.
    Now, when you start a song, to sequence the Nord, you just assign the Nord instrument to a track (by for instance, right clicking on a track and choosing your Nord instrument from the list of environment obects that appears).
    2) The multi instrument trick is quick and easy its great but How would I do that manually?
    Lots of ways, look into your key commands, ther are all kinds of "Create track with same instrument", "Create track with next MIDI channel" and so on. There are too many ways to do this to quickly talk about here. In short, all tracks have an environment object assigned to them, whether it's an audio object, or a MIDI instrument object, and this determines where the data on the track goes.
    3) How do you set up midi so that it doen'ts overwrite notes when recording over them?
    Not sure I understand you here...

  • A very very very simple question

    Hi guys,
    I have a very simple question and standard but I cant find anywhere...
    I have two dateTime variables, i need to calculate difference between this dates in days, thats it.
    I tried all functions and tried without success a Java Embed task but I couldnt retrieve this objects as java.util.Date so I couldnt calculate exactly the difference in days like this pure java code:
    (dataVencimento.getTime() - dataReferencia.getTime()) / 86400000L)
    can you help me this?

    Hi Jose
    Just see if these alternate approaches works. I know there may be lot like this and you may be lucky to find out simple out of box solution itself. If you want to solve this issue and move ahead, gives these approaches a shot.
    1. Create a very simple standalone WebService that takes 2 input date elements (can be of Date type or String type. If string type, convert to date in your java code). Create a simple operation like getDaysBetween(firstDate, secondDate). In the generated webservice impl class, use the java code apis (refer earlier link for usage), and get the difference. Return this value. NOW, invoke this WebService in your BPEL Process, and pass your 2 inputs (if the bpel payload elemetns are date object or string objects of date), and get output, and then use this output in your continuing bpel process.
    2. This approach, I did a long back. When we insert any expression using XPath, in that editor window on bottom right side, we see many categories and for each category we see list of functions we can use, like for String, we can use concat etc. I vaguely remember reading somewhere, that we can add our own custom functions also in this section. So explore this direction and see if you can add your own function and then use that fucntion with your 2 input dates.
    I have not given solution to your problem, but may be these directions can help you move ahead. Or something along these lines.
    Thanks
    Ravi Jegga

  • HOW can I convert int value char TO String

    I am trying to study Java by books, but sometimes it is quite difficult to find answers even to simple questions...
    I am writing a program that analyzes a Chinese text in Unicode. What I get from the text is CHAR int value (in decimals), and now I need to find them in another text file (with RegEx). But I can't find a way how to convert an INT value of a char into a String.
    Could you help me?
    Thank you in advance.

    You are confusing matters a bit. A char is a char is a char, no matter
    how you represent it. Have a look at this:char a= 'A';
    char b= 65;Both a and b have the same value. The representation of that value
    can be 'A' or 65 or even (char)('B'-1), because the decimal representation
    of 'B' is 66. Note the funny construct (char)(...). This construct casts
    the value ... back to the char type. Java performs all non-fraction
    arithmetic using four byte integers. The cast transforms it back to
    a two byte char type.
    Strings are just concatenations of zero or more chars. the charAt(i)
    method returns you the i-th char in a string. Have a look:String s= "AB";
    char a= 'A';
    char b= (char)(a+1);
    if (a == s.charAt(0)) System.out.println("yep");
    if (b == s.charAt(1)) System.out.println("yep");This piece of code prints "yep" two times. If you want to compare two
    Strings instead, you have to do this:String s= "AB";
    char a= 'A';
    char b= 'B';
    String t= ""+a+b;
    if (s.equals(t)) System.out.println("yep");Note the 'equals' method instead of the '==' operator. Also note that
    string t was constructed using those two chars. The above was a
    shorthand of something like this:StringBuffer sb= new StringBuffer("");
    sb.append(a);
    sb.append(b);
    String t= sb.toString();This is all handled by the compiler, for now, you can simply use the '+'
    operator if you want to append a char to a string. Note that it is not
    very efficient, but it'll do for now.
    Does this get your started?
    kind regards,
    Jos

  • Need to convert  Date from calendar to String in the format dd-mom-yyyy

    Need to convert Date from calendar to String in the format dd-mom-yyyy+..
    This is absolutely necessary... any help plz..
    Rgds
    Arwinder

    Look up the SimpleDateFormat class: http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
    Arwinder wrote:
    This is absolutely necessary... any help plz..For you maybe, not others. Please refrain from trying to urge others to answer your queries. They'll do it at their own pace ( if at all ).
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://faq.javaranch.com/java/HowToAskQuestionsOnJavaRanch
    (Yes I know it's on JavaRanch but I think it applies everywhere)
    ----------------------------------------------------------------

  • A simple Question about % in CR Chart!

    Hi, I have another simple question.
    When i use SQL to storage data and wanna Crystal Report to display the data in chart using %
    which data type should i use?
    float or string?
    and I found when i use 0.12 as 12% in database , It could not display in Crystal Report line chart normally.
    What should I do??
    Please Help!!!
    Thank you VERY MUCH!!!

    If you have the datatype as string from your database then try adding the string field as a summary field in chart and select maximum instead of count and if you have them in number format then you can directly select the percentage in chart.
    Regards,
    Raghavendra

  • Simple question about JAVA path

    Hi. I have a simple question , but I spent several hours trying to find an answer.
    How do I know the location of the java executable which is used by Concurrent Manager.
    I already know that running which java under application user will not give me the correct answer

    Maybe you can try like this:
         public String getPath(){
              Class cls=getClass();
              String className=cls.getName();
              String packageName=cls.getPackage().getName();
              System.out.println(className);
              System.out.println(packageName);
              String newClassName=className.replaceAll("\\.", "/");
              String resouceName=newClassName+".class";
              System.out.println(resouceName);
              URL url;
              url=cls.getClassLoader().getResource(resouceName);
              String path="";
              path=url.getFile();
              return path;
         }

  • Need a simple answer for simple question???

    simple question... what is the best way to export my fce movie and burn it on idvd for the best quality for genaral use ... sd..4x3 ratio tv.. lots of ken burn effects on photos... lots of sd video... ???
    not so simple answer... i have read manuals.. apple discussions.. etc etc my eyes are blurry.. i have been exporting out of fce to qk time movie, then import to idvd and burn..
    i get lots of wavy or jitter when doing kens burn effects on photos.. i have been told that 1 field must be missing.. and its better to take the qk time movie convert it again making sure hi quality is checked(movie properties 720 x 480) and self contained movie, then import to imovie ver 5.02 which has better codecs then to idvd ... an apple store tech said..
    then another apple store tech said...dv pro or dv stream or interlaced or on and on and on
    its not 16x9, or for the web or anything but simply burn it and give it to my grandma to play in a standard dvd player.. best quality.. period.. i know it won't any better than my source video but the wavy photos bother me..
    help

    The Apple store tech told you garbage. The quality will be the same. It's using the same QuickTime engine. There may be a difference because going through iMovie will go through a file conversion and the picture might be softened a little, which will mitigated this flicker you see.
    The wavy photos can be a lot of things, most likely due to the nature of the images themselves and the movements you've done on them. What often works on still images is to apply a one pixel vertical motion blur in an application like Photoshop or Elements. This helps to reduce interlace flicker on motion when the material is brought into a video editing application.

  • VERY SIMPLE QUESTION REGARDING UML DIAGRAMS IN JDEVELOPER

    Hello there,
    I have a very simple question. I want to know how I can convert a class diagram that I have created in jdeveloper into a jpg image so I can put in word. When I try exporting it only has the uml to xmi option
    Does anyone have a suggestion?

    Hi,
    Right mouse click on the class diagram,
    than click publish diagram on the context menu
    and save as jpg where ever you want...
    Boris

  • A very simple question..Very Urgent

    HI,
    I have a very simple question.I am able to set up the client authentication as well as server authentication. Now do i need to authenticate (both server as well as client auth.) for every request i send to the server on https...i think it should be like that it should authenticate only for the first time and for the next upcoming requests in same session should not require any server or client authentication.. i think as it happens in browsers..
    what is the fact actually??..can somebody put some light...right now in my case it is authenticating for every requests..
    This is what i have done..
    /****constructor part********/
    // and tm are arrays of keymanagers and trustmanagers for client keystore and truststore
    sslContext.init(km, tm, null);
    HttpsURLConnection.setDefaultSSLSocketFactory(ssf);
    HttpsURLConnection.setDefaultHostnameVerifier(new MYHostNameVerifier());
    /****Method to send the request and response*********/
    urlConn = (HttpsURLConnection)url.openConnection();
    urlConn.setDoInput(true);
    urlConn.setDoOutput(true);
    OutputStream os = urlConn.getOutputStream();
    ObjectOutputStream oos = new ObjectOutputStream(os);
    oos.writeObject(someobject);
    oos.flush();
    InputStream is1 = urlConn.getInputStream();
    ObjectInputStream ois = new ObjectInputStream(is1);
    SomeObject retObj = null;
    retObj = (SomeObject)ois.readObject();
    ois.close();
    System.out.println("Get String>>>>> "+retObj.getString());
    I am creating the object of this class..and calling the method again and again for sending requests and response..so i think handshake everytime i call the method...what i want is that handshake should happen for the first time and for the next requests no handshake or certificates should be checked or processed..
    is it possible ..how..what i need to do for that..
    please help me in this..
    Akhil Nagpal

    Hi,
    how could I achieve SSL Session Resumption using HttpsURLConnection.
    Thanks.

  • This is a very simple question,but I don't know.Please me.Thank you!

    I am a Chinese student in a university.I have a very simple question to ask.
    I have writed a EJB module,and I have deployed to Weblogic8.1 successfully.
    1.Now I want to write a client program.Is it necessary that the client program is packaged in the EJB package.For example ,the EJB package is Beans,is "package Beans " or "import Beans.*" necessary in my client program.
    2.If I only know the EJB interfaces,that means the EJB module is writed by other programer.I want to know how I can write the client program.How can I call EJB module's method writed by other programer.Could you give me a simple example?
    Thank you very much.

    I have writed a EJB module,and I have deployed to
    Weblogic8.1 successfully.:-)
    1.Now I want to write a client program.Is it
    necessary that the client program is packaged in the
    EJB package.For example ,the EJB package is Beans,is
    "package Beans " or "import Beans.*" necessary in my
    client program.You need not package your client with the EJB. It can be a JSP/servlet or a stand-alone application.
    2.If I only know the EJB interfaces,that means the
    EJB module is writed by other programer.I want to
    know how I can write the client program.How can I
    call EJB module's method writed by other
    programer.Could you give me a simple example?
    import java.util.*;
    import javax.naming.*;
    import javax.rmi.PortableRemoteObject;
    import examples.*;
    class TestEJBHello {
        public static void main(String[] args) {
            Context context   = null;
            Object object     = null;
            // Hashtable for environment properties.
            Hashtable env = new Hashtable();
            env.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
            env.put(Context.PROVIDER_URL, "t3://localhost:7001");
            HelloHome home            = null;
            HelloWorld hello          = null;
            try {
                context     = new InitialContext(env);
                object      = context.lookup("HelloWorldTest");
                System.out.println(" JNDI Looked up >>> " +object);
                home        = (HelloHome)PortableRemoteObject.narrow(object, HelloHome.class);
                hello       = home.create();
                System.out.println(hello.hello());
            } catch(Exception e) {
                e.printStackTrace();
            } finally {
                close(context);        // Closes the initial context.
        private static void close(Context context) {
            try {
                context.close();
                System.out.println("*** Context closed. ***");
            } catch (NamingException namingException) {
                namingException.printStackTrace();
            } catch(Exception exception) {
                exception.printStackTrace();
    }Here's a sample client app code I use for a HelloWorld EJB. You need to have a EJB client JAR containing the home and remote interfaces in the classpath during compile time and runtime.
    x

  • Reading Files (simple question)

    I'm doing some homework (and no, I'm not just looking for a handout answer, I just need a simple question answered) and I was wondering about how to read a word and evaluate if the word is the same as another word. I want to do this from a .txt file using the Scanner. I know I have to read the file and use while(ifp.hasNext()) but how do I evaluate it word by word? If there's anything else you need or if I'm asking the wrong question, let me know.

    Is there any other way to read through a file other than nextLine? I know there's probably a simpler answer, but the only way I could think of doing it is storing the next line as a String and trying to find the specified word in the string. Not only am I not sure how to do that, I imagine there's a better way. Should I be evaluating it a different way?
    Edit: I was looking at the javadoc on the Scanner class and I saw the findInLine method. We definitely didn't use this in our class, but is that what I should use?
    Edited by: Mikola7 on Nov 5, 2007 4:14 PM
    Edited by: Mikola7 on Nov 5, 2007 4:16 PM

  • Simple Question - Data Import

    Hi,
    i have a simple question. Is it wise to change our actual import scenarios for input data from systems out of sap to XI?
    Today we have the scenario that data from outer systems will send per ftp to a special directory. After that a report will transform the data into a batchinput. The btci will send per rfbibl into the system. Now we have a huge number of such reports. Will it now be better to change to XI, which we use perhaps for MDM?
    Xi could take the file from ftp-srever maps the fields an will send per bapi to sap.
    Is it a quite simple scenario or is batchinput still the better way.

    Hi,
    If you have a scenario where you have different file formats , which needs to be converted and then send to different systems based on some conditions , then suggested is XI usage.
    However, also if you already have XI installed and running for the MDM system , then you can think of routing all messages through XI.  It may make sense to use one system for all routing and data conversion puposes.
    Hope this view helps.
    Cheerio,
    Disha

Maybe you are looking for

  • External monitor doesn't work.

    hello, please look into my situation. i finally got the apple mini-dvi to dvi convertor, got a generic dvd-to-vga convertor and after removing 4 wires from it for which there is no space in the apple dvi output, i hooked up the sony sdm-hs75 display

  • Universal Dock and Remote

    I just bought a Transpod for my iPod VIDEO. I'm asking if the transpod is a universal dock. Also, if i by a universal dock with a remote, can i use the remote in my car?

  • Asset is incomplete problem

    Hi SAP Exparts, I have created 3 asset masters and assets PO also created. When I am doing MIGO (goods receipt) I have facing in the below massage. NA AAPO184 Short Text         Asset PS00 6000000-0 In complete, check the Asset Diagnosis    The ' Inc

  • Validity Period for BP relationships

    Hello Experts, We are having a problem with the validity date in BP relationship. Our partner functions get replicated from ECC to CRM. However, if one of the partner function detail changes, the relationship come up with two values for the same part

  • How do I configure the mixed signal graph property node to set the plot names

    I have a mixed signal graph displaying digital and analog data in two groups. I would like to programmatically set the names of individual plots i.e. rather that the digital graph displaying 'Digital 0->Line 0'  I would like to set it to 'Signal 1'