How can i initialize variables String[] ? (sorry if i'm flooding)

i have this class:
class Data{
        String subfolder;
        String[] citation = new String[2000];
        String[] reference = new String[2000];
    }but i need a constructor for it. What should i do? Thanks for your help

class Data{
String subfolder;
String[] citation = new String[2000];
String[] reference = new String[2000];
class Data{
  public String[] citation;
  public String[] reference;
  public String subfolder;
  Data(){
         subfolder = null;
         citation = new String[2000];
         reference = new String[2000];
String[] myString = new String[10];
for(int i=0; i<myString.length; i++){
  myString[i] = "myString" + i;
for(int i=0; i<myString.length; i++) System.out.println(myString);
When you do the new myString[10] you just make a string array with 10 elements, you still have to put something in each one before they don't equal null;

Similar Messages

  • How can i initialize variables and append variable in bpelx:exec

    I want to know how to initialize variables in bpelx:exec.
    I try to use java embedded activities for dynamic sql query. But I meet some problems that cannot assign the data to tempVariable. because I don't initialize tempVariable. but I can't initial variables in java embedded actitvities. How can i initialize variables in bpelx:exec ?
    and I want to know to extend child Elment of tempVariables dynamically in bpelx:exec ?
    here is my source.
    <bpelx:exec name="callEmpDB" language="java" version="1.5">
    <![CDATA[
    String url = "jdbc:oracle:thin:@127.0.0.1:1521:wonchoi";
    String user = "scott";
    String passwd = "tiger";
    int index = 1;
    Connection conn = null;
    Statement stmt = null;
    ResultSet rs = null;
    Node node = null;
    try{                             
    conn = DriverManager.getConnection (url, user, passwd);
    stmt = conn.createStatement();
    String wherescript = "";
    Element empno = (Element)getVariableData("inputVariable","payload", "/client:selConnectDBProcessRequest/client:empno");
    Element ename = (Element)getVariableData("inputVariable","payload", "/client:selConnectDBProcessRequest/client:ename");
    Element job = (Element)getVariableData("inputVariable","payload", "/client:selConnectDBProcessRequest/client:job");
    Element deptno = (Element)getVariableData("inputVariable","payload", "/client:selConnectDBProcessRequest/client:deptno");
    String sql = "select empno, ename, job, mgr, hiredate, sal, comm, deptno from emp where 1 = 1 ";
    if(empno != null && empno.getTextContent() != null && !empno.getTextContent().equals("") )
    wherescript = wherescript + " and empno = " + empno.getTextContent() ;
    if(ename != null && ename.getTextContent() != null && !ename.getTextContent().equals("") )
    wherescript = wherescript + " and ename like '" + ename.getTextContent() +"' " ;
    if(job != null && job.getTextContent() != null && !job.getTextContent().equals("") )
    wherescript = wherescript + " and job = '" + job.getTextContent() +"' ";
    if(deptno != null && deptno.getTextContent() != null && !deptno.getTextContent().equals("") )
    wherescript = wherescript + " and deptno = " + deptno.getTextContent() ;
    sql = sql + wherescript;
    System.out.println("sql : "+sql);
    rs = stmt.executeQuery(sql) ;
    while (rs.next())
    setVariableData("tempVariable", "payload", "/ns1:selEmpOutputCollection/child::*[position()="+index+"]/ns1:EMPNO", rs.getString("empno"));
    setVariableData("tempVariable", "payload", "/ns1:selEmpOutputCollection/child::*[position()="+index+"]/ns1:ENAME", rs.getString("ename"));
    setVariableData("tempVariable", "payload", "/ns1:selEmpOutputCollection/child::*[position()="+index+"]/ns1:JOB", rs.getString("job"));
    setVariableData("tempVariable", "payload", "/ns1:selEmpOutputCollection/child::*[position()="+index+"]/ns1:MGR", (rs.getString("mgr")==null? "": rs.getString("mgr")));
    setVariableData("tempVariable", "payload", "/ns1:selEmpOutputCollection/child::*[position()="+index+"]/ns1:HIREDATE", rs.getString("hiredate"));
    setVariableData("tempVariable", "payload", "/ns1:selEmpOutputCollection/child::*[position()="+index+"]/ns1:SAL", rs.getString("sal"));
    setVariableData("tempVariable", "payload", "/ns1:selEmpOutputCollection/child::*[position()="+index+"]/ns1:COMM", rs.getString("comm"));
    setVariableData("tempVariable", "payload", "/ns1:selEmpOutputCollection/child::*[position()="+index+"]/ns1:DEPTNO", rs.getString("deptno"));
    index++;
    }catch(SQLException sex){                          
    System.out.println("sql error");
    }catch(Exception ex){                             
    System.out.println("error");
    }finally{                             
    try{                      
    rs.close();
    stmt.close();
    conn.close();
    }catch(Exception ex){}
    }]]>
    </bpelx:exec>
    and here is tempVariable examples and schema.
    <tempVariable>
         <part name="payload">
              <selEmpOutputCollection>
                   <selEmpOutput>
                   <EMPNO/>
                   <ENAME/>
                   <JOB/>
                   <MGR/>
                   <HIREDATE/>
                   <SAL/>
                   <COMM/>
                   <DEPTNO/>
              </selEmpOutput>
              <selEmpOutputCollection>
         </part>
    </tempVariable>     
    <xsd:element name="selEmpOutputCollection" type="selEmpOutputCollection"/>
    <xsd:element name="selEmpOutput" type="selEmpOutput"/>
    <xsd:complexType name="selEmpOutputCollection">
    <xsd:sequence>
    <xsd:element name="selEmpOutput" type="selEmpOutput" minOccurs="0" maxOccurs="unbounded"/>
    </xsd:sequence>
    </xsd:complexType>
    <xsd:complexType name="selEmpOutput">
    <xsd:sequence>
    <xsd:element name="EMPNO" type="xsd:decimal" nillable="true"/>
    <xsd:element name="ENAME" type="xsd:string" nillable="true"/>
    <xsd:element name="JOB" type="xsd:string" nillable="true"/>
    <xsd:element name="MGR" type="xsd:decimal" nillable="true"/>
    <xsd:element name="HIREDATE" type="xsd:dateTime" nillable="true"/>
    <xsd:element name="SAL" type="xsd:decimal" nillable="true"/>
    <xsd:element name="COMM" type="xsd:decimal" nillable="true"/>
    <xsd:element name="DEPTNO" type="xsd:decimal" nillable="true"/>
    </xsd:sequence>
    </xsd:complexType>
    thanks

    My bpel project flow is as follows.
    First, I initalize the temp varialbe like this.
    <assign name="setInitialVar">
    <copy>
    <from>
    <ns1:selEmpOutput xmlns:ns1="http://lgesoa.lge.com/EmpSpec/types">
    <ns1:EMPNO/>
    <ns1:ENAME/>
    <ns1:JOB/>
    <ns1:MGR/>
    <ns1:HIREDATE/>
    <ns1:SAL/>
    <ns1:COMM/>
    <ns1:DEPTNO/>
    </ns1:selEmpOutput>
    </from>
    <to variable="tempVariable" part="payload"
    query="/ns1:selEmpOutputCollection/ns1:selEmpOutput"/>
    </copy>
    </assign>
    Second, get Data(ex. 10 Employee Information List) from DB for useing Java embedded activity.
    Third, assing employee info to tempVariable, then BPEL assign just only one Employee Information. and next data can't assign and the BPEL make an error.
    here is my error message..
    <2007-03-02 11:23:26,125> <ERROR> <default.collaxa.cube.engine> <BPELXExecLet::setVariableData>
    com.oracle.bpel.client.BPELFault: faultName: {{http://schemas.xmlsoap.org/ws/2003/03/business-process/}selectionFailure}
    messageType: {null}
    parts: {{summary=oracle.xml.parser.v2.XMLElement@15f80b}}
         at com.collaxa.cube.xml.dom.DOMUtil.copy(DOMUtil.java:536)
         at com.collaxa.cube.engine.ext.BPELXExecLet.setVariableData(BPELXExecLet.java:721)
         at com.collaxa.cube.engine.ext.BPELXExecLet.setVariableData(BPELXExecLet.java:700)
         at bpel.selconnectdb.ExecLetBxExe4.execute(ExecLetBxExe4.java:160)
         at com.collaxa.cube.engine.ext.wmp.BPELXExecWMP.__executeStatements(BPELXExecWMP.java:49)
         at com.collaxa.cube.engine.ext.wmp.BPELActivityWMP.perform(BPELActivityWMP.java:195)
         at com.collaxa.cube.engine.CubeEngine.performActivity(CubeEngine.java:3271)
         at com.collaxa.cube.engine.CubeEngine.handleWorkItem(CubeEngine.java:1697)
         at com.collaxa.cube.engine.dispatch.message.instance.PerformMessageHandler.handleLocal(PerformMessageHandler.java:75)
         at com.collaxa.cube.engine.dispatch.DispatchHelper.handleLocalMessage(DispatchHelper.java:184)
         at com.collaxa.cube.engine.dispatch.DispatchHelper.sendMemory(DispatchHelper.java:269)
         at com.collaxa.cube.engine.CubeEngine.endRequest(CubeEngine.java:5244)
         at com.collaxa.cube.engine.CubeEngine.createAndInvoke(CubeEngine.java:1083)
         at com.collaxa.cube.engine.ejb.impl.CubeEngineBean.createAndInvoke(CubeEngineBean.java:132)
         at com.collaxa.cube.engine.ejb.impl.CubeEngineBean.syncCreateAndInvoke(CubeEngineBean.java:161)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    I analyzed the problem. and I find the reason that is I just assing one XML flag to the temp variable. If i don't initalize the varaible like first step, BPEL make an error above error message.
    thanks
    Won.

  • How  can use a variable in the folowing code?

    How  can use a variable 'W_ROWNUM2' in the folowing code?
    MOVE '1' TO CNT.
    LOOP AT L_T_PM2.
                  CONCATENATE '0' CNT INTO W_ROWNUM2.CONDENSE W_ROWNUM2.
                   CONCATENATE 'F110V-VARI'W_ROWNUM2'(01)' INTO FLD2.
        perform  DYNPRO_FIELD       using FLD2
                                     L_T_PM2-vari12_con.
                   CNT = CNT + 1.
                   CONDENSE CNT.                                                              
    ENDLOOP.
    I need to increment the value of W_ROWNUM2.
    Please ,it is urgent!!

    Hello
    CONCATENATE 'F110V-VARI'W_ROWNUM2'(01)' INTO FLD2.
    Try using spaces between parts of the resulting string.
    CONCATENATE 'F110V-VARI'  W_ROWNUM2  '(01)'   INTO FLD2
    Regards
    Greg Kern.

  • How can i write a string into a specified pos of a file?

    How can i write a string into a specified pos of a file without read all file into ram and write the whole file again?
    for example:
    the content of file is:
    name=123
    state=456
    i want to modify the value of name with 789
    (write to file without read all file into ram)
    How can i do it? thank you

    take this as an idea. it actually does what i decribed above. you sure need to make some modifications so it works for your special need. If you use it and add any valuable code to it or find any bugs, please let me know.
    import java.io.*;
    import java.util.*;
    * Copyright (c) 2002 Frank Fischer <[email protected]>
    * All rights reserved. See the LICENSE for usage conditions
    * ObjectProperties.java
    * version 1.0, 2002-09-12
    * author Frank Fischer <[email protected]>
    public class ObjectProperties
         // the seperator between the param-name and the value in the prooperties file
         private static final String separator = "=";
         // the vector where we put the arrays in
         private Vector PropertiesSet;
         // the array where we put the param/value pairs in
         private String propvaluepair[][];
         // the name of the object the properties file is for
         public String ObjectPropertiesFileName;
         // the path to the object'a properties file
         public String ObjectPropertiesDir;
         // reference to the properties file
         public File PropertiesFile;
         // sign for linebreak - depends on platforms
         public static final String newline = System.getProperty("line.separator");
         public ObjectProperties(String ObjectPropertiesFileName, String ObjectPropertiesDir, ObjectPropertiesManager ObjectPropertiesManager)
         //     System.out.println("Properties Objekt wird erzeugt: "+ObjectPropertiesFileName);
              this.ObjectPropertiesFileName = ObjectPropertiesFileName;
              this.ObjectPropertiesDir = ObjectPropertiesDir;
              // reference to the properties file
              PropertiesFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
              // vector to put the param/value pair-array in
              PropertiesSet = new Vector();
         //     System.out.println("Properties File Backup wird erzeugt: "+name);
              backup();
         //     System.out.println("Properties File wird eingelesen: "+PropertiesFile);
              try
                   //opening stream to file for read operations
                   FileInputStream FileInput = new FileInputStream(PropertiesFile);
                   DataInputStream DataInput = new DataInputStream(FileInput);
                   String line = "";
                   //reading line after line of the properties file
                   while ((line = DataInput.readLine()) != null)
                        //just making sure there are no whitespaces at the beginng or end of the line
                        line = cutSpaces(line);
                        if (line.length() > 0)
                             //$ indicates a param-name
                             if (line.startsWith("$"))
                                  // array to store a param/value pair in
                                  propvaluepair = new String[1][2];
                                  //get the param-name
                                  String parameter = line.substring(1, line.indexOf(separator)-1);
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  parameter = cutSpaces(parameter);
                                  //get the value
                                  String value = line.substring(line.indexOf(separator)+1, line.length());
                                  //just making sure there are no whitespaces at the beginng or end of the variable
                                  value = cutSpaces(value);
                                  //put the param-name and the value into an array
                                  propvaluepair[0][0] = parameter;
                                  propvaluepair[0][1] = value;
                             //     System.out.println("["+ObjectPropertiesFileName+"] key/value gefunden:"+parameter+";"+value);
                                  //and finaly put the array into the vector
                                  PropertiesSet.addElement(propvaluepair);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while reading property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   // System.out.println("in ObjectProperties");
         // function to be called to get the value of a specific paramater 'param'
         // if the specific paramater is not found '-1' is returned to indicate that case
         public String getParam(String param)
              // the return value indicating that the param we are searching for is not found
              String v = "-1";
              // looking up the whole Vector
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = new String[1][2];
                   // trying to get out the array from the vector again
                   s = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we look up the value and write it in the return variable
                        v = s[0][1];
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // giving the value back to the calling procedure
              return v;
         // function to be called to set the value of a specific paramater 'param'
         public void setParam(String param, String value)
              // looking up the whole Vector for the specific param if existing or not
              for (int i=0; i<PropertiesSet.size(); i++)
                   //the String i want to read the values in again
                   String s[][] = (String[][]) PropertiesSet.elementAt(i);
                   // comparing the param-name we're looking for with the param-name in the array we took out the vector at position i
                   if (s[0][0].equals(param) == true)
                        //if the param-names are the same, we remove the param/value pair so we can add the new pair later in
                        PropertiesSet.removeElementAt(i);
                        // making sure the for loop ends
                        i = PropertiesSet.size();
              // if we land here, there is no such param in the Vector, either there was none form the beginng
              // or there was one but we took it out.
              // create a string array to place the param/value pair in
              String n[][] = new String[1][2];
              // add the param/value par
              n[0][0] = param;
              n[0][1] = value;
              // add the string array to the vector
              PropertiesSet.addElement(n);
         // function to save all data in the Vector to the properties file
         // must be done because properties might be changing while runtime
         // and changes are just hold in memory while runntime
         public void store()
              backup();
              String outtofile = "# file created/modified on "+createDate("-")+" "+createTime("-")+newline+newline;
              try
                   //opening stream to file for write operations
                   FileOutputStream PropertiesFileOuput = new FileOutputStream(PropertiesFile);
                   DataOutputStream PropertiesDataOutput = new DataOutputStream(PropertiesFileOuput);
                   // looping over all param/value pairs in the vector
                   for (int i=0; i<PropertiesSet.size(); i++)
                        //the String i want to read the values in
                        String s[][] = new String[1][2];
                        // trying to get out the array from the vector again
                        s = (String[][]) PropertiesSet.elementAt(i);
                        String param = "$"+s[0][0];
                        String value = s[0][1];
                        outtofile += param+" = "+value+newline;
                   outtofile += newline+"#end of file"+newline;
                   try
                        PropertiesDataOutput.writeBytes(outtofile);
                   catch (IOException e)
                        System.out.println("ERROR while writing to Properties File: "+e);
              catch (IOException e)
                   System.out.println("ERROR occured while writing to the property file for: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
         // sometimes before overwritting old value it's a good idea to backup old values
         public void backup()
              try
                   // reference to the original properties file
                   File OriginalFile = new File(ObjectPropertiesDir+ObjectPropertiesFileName);
                   File BackupFile = new File(ObjectPropertiesDir+"/backup/"+ObjectPropertiesFileName+".backup");
                   //opening stream to original file for read operations
                   FileInputStream OriginalFileInput = new FileInputStream(OriginalFile);
                   DataInputStream OriginalFileDataInput = new DataInputStream(OriginalFileInput);
                   //opening stream to backup file for write operations
                   FileOutputStream BackupFileOutput = new FileOutputStream(BackupFile);
                   DataOutputStream BackupFileDataOutput = new DataOutputStream(BackupFileOutput);
              //     String content = "";
                   String line = "";
                   // do till end of file
                   while ((line = OriginalFileDataInput.readLine()) != null)
                        BackupFileDataOutput.writeBytes(line+newline);
              // error handlig
              catch (IOException e)
                   System.out.println("ERROR occured while back up for property file: "+ObjectPropertiesFileName);
                   System.out.println("ERROR CODE: "+e);
                   System.out.println("this is a serious error - the server must be stopped");
         private String cutSpaces(String s)
              while (s.startsWith(" "))
                   s = s.substring(1, s.length());
              while (s.endsWith(" "))
                   s = s.substring(0, s.length()-1);
              return s;
         public String createDate(String seperator)
              Date datum = new Date();
              String currentdatum = new String();
              int year, month, date;
              year = datum.getYear()+1900;
              month = datum.getMonth()+1;
              date = datum.getDate();
              currentdatum = ""+year+seperator;
              if (month < 10)
                   currentdatum = currentdatum+"0"+month+seperator;
              else
                   currentdatum = currentdatum+month+seperator;
              if (date < 10)
                   currentdatum = currentdatum+"0"+date;
              else
                   currentdatum = currentdatum+date;
              return currentdatum;
         public String createTime(String seperator)
              Date time = new Date();
              String currenttime = new String();
              int hours, minutes, seconds;
              hours = time.getHours();
              minutes = time.getMinutes();
              seconds = time.getSeconds();
              if (hours < 10)
                   currenttime = currenttime+"0"+hours+seperator;
              else
                   currenttime = currenttime+hours+seperator;
              if (minutes < 10)
                   currenttime = currenttime+"0"+minutes+seperator;
              else
                   currenttime = currenttime+minutes+seperator;
              if (seconds < 10)
                   currenttime = currenttime+"0"+seconds;
              else
                   currenttime = currenttime+seconds;
              return currenttime;

  • How can i initialize a button (Switch when pressed) to be always disabled when i start the programm.

    Hello
    How can i initialize a button (Switch when pressed) to be always disabled when i start the programm. My problem is that the state of the button is always the state in which it finihed last time.
    Thanks
    Lukas

    A button is either true or false. "Disabled" is a property that determines if the button can be operated or not.
    It seems from the rest of your question that you actually want to ensure that it is set to false, but remain enabled. This is easiest done with a local variable as already mentioned by becktho.
    If you want to disable the button, use a property node.
    LabVIEW Champion . Do more with less code and in less time .

  • How can I send multiple string commands into a VISA write?

    Hi Fellow LabVIEW users
    I am very new to LabVIEW (2.5 months) so please forgive me if my lingo is not up to par.
    How can I send multiple string commands to a VISA write. For example each string command looks like this
    1) 3A00 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0033 (Scenario 1)
    2) 3A01 0000 0000 FFFF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0034 (Scenario 2)
    3) 3A01 0000 0000 33FF FFFF FFFF 0000 0000 FF00 0000 0000 0000 0000 0067 (Scenario 3).
    and so on and so forth. And there are a number of scenarios.
    Each String scenario will give a different string output which will be interpreted differently in the front panel.
    Right now I have to manually change the string commands on the front panel to give me the desired output. How can I do this without manually changing the commands i.e. hard coding each scenario into the block diagram?
    Thanks, any feedback will help.
    mhaque

    Please stick to your original post.

  • How can i extract data strings (temp. press. rel.hum etc) using a Virtual interface through an RS-232 connection​?

    How can i extract data strings (temperature, pressure, relative humidity etc) using a Virtual interface through an RS-232 connection?

    Try this.  It is in LV 8.5.
    Note the double % in the format string.  This is so the % in the input string is treated as a percent rather than a code.
    You may also have to work with the line feed characters in case they are different in the string coming in compared to how the string shows up in the web browser.
    Message Edited by Ravens Fan on 02-12-2008 10:19 PM
    Attachments:
    Example_BD.png ‏4 KB
    Untitled 11.vi ‏9 KB

  • How can I convert a string to a seperated characters?

    How can I convert a string to a separated characters without using array?
    such as: input = String "word"
    output =
    w
    o
    r
    d
    Thanks

    A string is stored internally in individual characters.
    The String class has a method 'charAt(int index)' which returns the character at that index so using a for loop..
    String s = "word";
    for(int counter=0; counter < s.length(); counter++)
    System.out.println(s.charAt(counter));
    HTH

  • How can I re-organize String lines

    Hello My String consists of random lines. Every line has an priority number. Example of a String:
    Done     id     pri     created          finished     description     
         000     1     2006-12-11     -          job     
    x     001     2     2006-12-11     -     do this     
         002     3     2006-12-11     -          work
    x     003     0     2006-12-11     -          some
         004     2     2006-12-11     -          thing
         005     1     2006-12-11     -          reads
         006     0     2006-12-11     -          here
    Every "token" is seperated by \t (done \t id \t ....\t 000 \t 1 \t 2006-12-12 \t...)
    How can I organize the String and save it to another String so that pri-values are in a descending order:
    Done     id     pri     created          finished     description     
    002     3     2006-12-11     -          work
    x     001     2     2006-12-11     -     do this     
    004     2     2006-12-11     -          thing
    000     1     2006-12-11     -          job     
    005     1     2006-12-11     -          reads
    x     003     0     2006-12-11     -          some
         006     0     2006-12-11     -          here

    I'm trying but I don't know what I'm doing
    import java.io.*;                
    import java.util.*;                    
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.List;
    import java.util.Comparator;
    public class Start {
    public static void main(String[] args) throws IOException {
    sort();
    public static void sort() throws IOException  {
         class Work implements Comparable {
         String id;
         int pri;
         String d1;
         String d2;
         String job;
         public Work(String id, int pri, String d1, String d2, String job){
              this.id = id;
              this.pri = pri;
              this.d1 = d1;
              this.d2 = d2;
              this.job = job;
         BufferedReader reader = new BufferedReader(new FileReader("Tehtava.txt"));
         //BufferedWriter writer = new BufferedWriter(new FileWriter("Tempo.txt"));
         String lookingFor3 = "-";
         String line = null;
         while ((line = reader.readLine()) != null) {     //---------------z
                   String[]result = line.split("\t");
                   List tasks = new ArrayList();
                   if (result[4].equals(lookingFor) == true) {     
                   tasks.add(new Work(line));     
                   continue;
                   public int getpri()     {
                   return pri;          }
                   public int compareTo(Object o)     {
                   Work otherWork = (Work) o;
                   return this.getpri().compareTo(otherWork.getpri());     }
              Collections.sort(tasks); //-------------------x
              System.out.print(tasks); //------------------x
              //reader.close();
    }I don't know what but Where and I'm getting errors like:
    <identifier> expected
    for lines ------------x
    illegal start of type:
    for line -------------z

  • Dear sir! How can i judge a string's encoding?

    Dear sir! How can i judge a string's encoding?
    Now i receive a string !but i do not known what encoding this string is? I want a method to judge the encoding.
    Thank you!

    Strings in Java are by definition in Unicode. If you want to convert them to a specific encoding, you can do this:
    String yenSign = new String("\u00A5");
    byte[] yenByteArray = yenSign.getBytes("UTF8");
    Now yenByteArray is encoded into bytes using UTF-8.

  • How can I initialize the xScale of a xygraph with a string like '03-00010' ?

    I have two arrays. the first one is an array with decimal numbers (i.e. 0.9 ; 1.2 ; 5.0) and the second array is a string array (i.e. 03-01; 03-23; 05-001). I want to plot the pairs of values with a xygraph. How can I format the second array to scale the x-axis?

    The only thing that an XY graph can plot is two numeric arrays - not strings. Either axis can display a numeric as date/time so if your string values represent this, then you convert the strings and do it. You could put the string values in an adjacent indicator and use a legend i.e. 1=03-01,2=03-23.

  • Need Help ! how can I Pass Variable from JApplet to PHP?

    I think I post to the wrong forum and I don't know how to change.
    Sorry for messing thing.
    I try to send variable for applet to php but the result is no data was recorded in my database.
    I think the data did not transfer to php.
    I am familiar with php but new to java.
    Actually, I don't know how to send the variable for applet.
    For example, in PHP will receive $_POST['score'] so in applet, I need to send the variable name "score".
    In the book that I use for self-study, mention about servlet but I think PHP is much easier to me.
    So I need to know how set this request data to my applet.
    In internet, I still not get what is clear for me to understand.
    Or I may search with worng keyword or way.....
    Can someone please help me?
    public class test extends JApplet { public test(){ JButton myButton = new JButton("sendData");         myButton.setFont(new Font("Sansserif", Font.PLAIN, 14));         myButton.setSize(15, 10);                 myButton.addActionListener(new button());         add(myButton); } private class button implements ActionListener {         public void actionPerformed(ActionEvent e) {         PostMsg(10,"hello");         } } public void PostMsg(int score, String name){ try {             String data = "name=" + name + "score=" + score;                    byte[] parameterAsBytes = data.getBytes();      // Send data     URL url = new URL("http://localhost/addtest.php");     URLConnection con = url.openConnection();     ((HttpURLConnection) con).setRequestMethod("POST");          con.setDoOutput(true);          con.setDoInput(true);          con.setUseCaches(false);          OutputStream wr = con.getOutputStream();              wr.write(parameterAsBytes);     wr.flush();     // Get the response     BufferedReader rd = new BufferedReader(new InputStreamReader(con.getInputStream())); wr.close();     rd.close(); } catch (Exception e) { System.out.println("ERROR"+e.getMessage()); } } }
    <html> <title>Untitled Document</title> </head> <body> include("../connectionJAVA/connect.php"); $name = $_POST['name']; $score =$_POST['score']; //insert data $sql = "insert into java values(null,'$name','$score')"; mysql_query($sql) or die("error=$sql"); </body> </html>

    rinJava wrote:
    I think I post to the wrong forum and I don't know how to change.Yep wrong forum. This is probably a html/applet/web service sort of question.

  • Using SKPTSMTPMessage how to send a variable String?

    I am using SKPTSMTPMessage to send an email in the background but I need to send a variable string. I have tried putting a %@ in the text but it just sends the %@ and not a variable. Please Help?
    Hopefully, iCrazy23

    Did you ever figure out how to do this?  Because actually I'm trying to do pretty much exactly the same thing.  I'm actually having trouble even outputting the digital signal at all with my USB-6501.  I was initially trying to use DAQ Assistant, but then found out I probably shouldn't be using this and instead should be using the DAQmx individual functions.  I was directed by NI Support to look at the example "Gen Dig Pulse Train-Continuous.vi," but I haven't been able to figure out how to use this for my application.   For my project I  want to send a TTL signal to vavles that release fluids as well.  I have 3 2-way liquid releasing valves that I want to be synced so that only one is open at a time (for a user specified amount of time), and they open in a regular repeating sequence.  I also have another 3-way valve controlling a vacuum that I would like to be continuously pulsing, but for specified amounts of time (e.g., 3 seconds open, 3 seconds closed, and so on).
    I believe I can figure out the logic and the programming involved with figuring out the exact sequencing and timing manipulation, however, I'm having trouble just being able to output any digital signal with a varying time.  If you could offer any help on this, it would be greatly appreciated.  Thanks!

  • How can I pass a String by reference in java?

    Hello!
    My question is how to pass a String by reference in java.
    I tried to declare my variable, instead of using "String xxx = "f";", I used "String xxx = new String ("f");" :
    public static void main (String []args)
    String xxx = new String("f");
    StatusEnum result2 = getErrorPointStr(xxx);
         public StatusEnum getErrorPointStr(String text)
              StatusEnum testStatus = StatusEnum.PASS;
              StringBuffer buffer = new StringBuffer();
    buffer.append("123");
              text = buffer.toString();
              return testStatus;
    After calling to getErrorPointStr(String text) function, xxx = "f"
    So it does not work.
    How can I solve this? It is very important, the function will receive String and not something else.
    Thanks!

    Tolls wrote:
    Which is why I said:
    Which is why you only managed to change what 'text' referred to in the methodExcept that's not why. Even if String was mutable, doing text = whatever; would have the same effect; it would change what that variable refers to in the method, but it would not change the object's state.
    I meant that, since there was no way to actually change the data (ie the char[] or whatever) within the object 'text' referred to, the OP was attempting to change what 'text' referred to and hoping it would be reflected outside the method...which we know won't happen as Java is pass-by-value.\Ah, now I see.
    These by-value/by-reference threads tend to get confusing, because usually the person is passing a String, so the immutability of String tends to get in the way and just muddy the waters.

  • How can I convert a String into an int?

    I need to use command-line args. So I enter "java Main 123" and I want to use 123 not as a String but as an int.
    How can I convert it into an int?
    Thank You!!
    Sprocket

    Example method (you don't need to use a method unless you do this a lot)
    private int stringTOInt (String aString)
    int result = 0;
    try
    result = Integer.parseString(aString);
    catch (Exception ex)
    System.out.println ("Failed to convert string " + aString + " to int.");
    return result;
    }

Maybe you are looking for