Split Function in Java 1.4

Hi,
I tried the new split function in the Java 1.4 and it works except with some characters like '|' and '[' .
Please review the code below let me now the suggestions.
/***********Program******************/
class SplitCheck
     public static void main(String args[])
          String aSplit[];
          aSplit="ABC|1|a".split("|");
          for (int i=0;i<aSplit.length;i++)
               System.out.println("String=" + aSplit);
/***********Program******************/
The out program is expected to be like this.
String=ABC
String=1
String=a
But I got it as
String=
String=A
String=B
String=C
String=|
String=1
String=|
String=a
Is there any exception in using the split function.
Waiting for your reply,
Sham

I think that was a bad idea to push a regex functionality
into a java.lang.String directly...

Similar Messages

  • Split function failed with '&'

    Hi, I'm using the split function to retrieve some values, like this:
    String s_id = request.getParameter("id");
    String[] id_array=s_id.split("�");
    if (id_array != null){
         out.println(id_array[0]);
         out.println(id_array[1]);
    It works almost fine, except when the "id" field contains '&', then I got an error:
    java.lang.ArrayIndexOutOfBoundsException: 1
    Does anyone have any idea?!
    thanks..

    oops, my code was a bit messed up with the formatting...
    try one more time......
    if(s_code.equalsIgnoreCase("Participant1")){
                             while(i3.hasMoreElements()){
    final Participant1VO vo = (Participant1VO)i3.nextElement();
    out.println("<tr><td><a href=\"insert_code.jsp?id=" + StringUtil.escape(vo.getParticipant1()) + "�" + StringUtil.escape(s_code) + "\">"+ vo.getParticipant1() +" </a></td>" +
                   "</td><td> <input type='checkbox' name='checked' value= " + vo.getParticipant1() + "> " + "</td></tr>" );

  • Order split functionality with PP-PI

    Hello Forum,
    I am not sure whether we can use the order split functionality with process orders .  I had implemented it earlier for a client with discrete MFG production type but not aware whether we can do so in process industry (couldn't find the provision to do so in process order operation overview screen function menu path).
    Cheers
    Kaushik

    Hi Kaushik,
    Yes your right.
    Order split functionality is only applicable for Discrete manfg not for PI industry this is major difference between PI & DM.But you can achieve this at the time of process order confirmation.
    Example :-In the Goods Movement Overview of Process Order confirmation FG material is done Auto GR. This FG material Quantity needs to be splitted. Push button "Split" is provided in the bottom of the Goods Movement Overview screen of Process Order Confirmaton.
    Say FG quantity = 25 KG  which is to be confirmed. Client wants to split the FG quantity into 1 KG wise, for this he needs to split into 25 times.
    You can implement this by using below work order
    Please use the WORKORDER_GOODSMVT for splitting the GR in Confirmation
    This u can implement in PI.Also check Mr.Paulo reply that could be one possibility.
    check & revert.
    TnX

  • Problem in using Split function

    Hello,
    I have a problem using the Split function and I can't find any solution in internet.
    I'm trying to make a list of int but it seems that the Split function doesn't work.
    Can you help me please ?
    Here is my code :
    public class Dessin
            List<Forme> dessin = new List<Forme>();
            public void Ajouter(Forme forme)
                dessin.Add(forme);
            public void Lecture()
                StreamReader monStreamReader = new StreamReader("ExempleTout.csv");
                int ligne = int.Parse(monStreamReader.ReadLine());
                while (ligne != null)
                    int[] temp = ligne.Split(';');        // Error : 'int' doesn't contain a definition for 'Split'
                    if (temp[0].Equals("Cercle"))
                        Cercle cercle1 = new Cercle(temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], temp[7], temp[8]);
                    ligne = int.Parse(monStreamReader.ReadLine());
                foreach (Cercle c in dessin)
                    Console.WriteLine(c.ToString());
                    Console.ReadKey();
                Console.ReadKey();
                monStreamReader.Close();
    Best regards,

    Split is a method of string, not int. You are looking for strings anyway, I don't know why you'd parse to an int to begin with. Try this:
    string ligne = monStreamReader.ReadLine();
    while (ligne != null)
    string[] temp = ligne.Split(';');
    if (temp[0].Equals("Cercle"))
    Cercle cercle1 = new Cercle(int.Parse(temp[1]), int.Parse(temp[2]), int.Parse(temp[3]), int.Parse(temp[4]), int.Parse(temp[5]), int.Parse(temp[6]), int.Parse(temp[7]), int.Parse(temp[8]));
    ligne = monStreamReader.ReadLine();
    ~~Bonnie DeWitt [C# MVP]
    http://geek-goddess-bonnie.blogspot.com

  • User defined function in java for message mapping

    I wrote the following user defined function in java for message mapping and mapped vendor with this. The aim of this function is to write a error file at defined path when i send empty Vendor value from File to RFC-Function module BAPI_PO_CREATE. The "err.txt" error file is not written when i execute in TEST but the value "ERROR" is returned to destination Vendor Field.
    public String  validation(String a, Container container) {
    //write your code here
    if (a.equals("")) {
    try {
    String source = "Vendor cannot be empty";
    char buffer[] = new char[source.length()];
    source.getChars(0, source.length(), buffer, 0);
    for (int i = 0; i < buffer.length; i +=2)
       f0.write(buffer<i>);
    f0.close();
    FileWriter f1 =  new FileWriter("/10.10.0.55/sapmnt/trans/edixiin/err.txt");
    f1.write(buffer);
    f1.close();
    catch (IOException e) {}
    return "ERROR";

    Hi Senthil,
    Check these things :
    1) Whether you have permission to create a file in that directory.
    2) try giving this 
    10.10.0.55
    sapmnt
    trans
    edixiin
    err.txt
    3) Also check for permissions.
    Hope this will help you.
    Regards
    Suraj

  • Writing message mapping function in Java in integration repository

    Hi XI Pundits,
    I am new to XI. I was working on Message mapping in intergration repository.
    To map the source messages to target messages, we do graphical kind of mapping like drag and drop.
    There are some functions aavilable at the bottom like concatehate, trim and etc. which we use if we need to modify the source message and map to target.
    But in case we face a situation when we don't find the function which suits our requirement, I guess we need to write a new function. We can write these new function using Java only.
    Can someone throw some light on this ?
    <b>What do we do to invoke java editor in integartion reposity to write mapping function in java ?
    Can someone give an example of snippet of code ?</b>
    Thanks.

    Hi Tushar,
    Go thro this help link. You will get all info about User defined function.
    http://help.sap.com/saphelp_nw04/helpdata/en/22/e127f28b572243b4324879c6bf05a0/frameset.htm
    To get more understanding on mapping go thro this link(PDF File)
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9202d890-0201-0010-1588-adb5e89a6638
    Hope this helps.
    regards,
    P.Venkat
    Message was edited by: Venkataramanan

  • Can we call java function in java script????

    hello
    please tell me can i call a java function through java script function in jsp???

    of course not. JavaScript is interpreted by the client (web browser) while the Java code in a JSP resides on the server. don't confuse the web application's architecture.
    robert

  • FM call from Variant Function in JAVA SCE

    Hello,
    I have an issue with Variant Configuration in CRM WEB UI / WebShops.
    We have created a variant function in ECC to read/pull a customer master value (KNVV table).  This is working fine in ECC & got the desired result.
    Now we need replicate the same in CRM. For this we need to create KB, Version & write a variant function in Java class in SCE. In that variant function we need to call a function module and get the customer master / Business partner value as similar to ECC process described above.
    But we see that the SAP standard is not supporting FM calls from VF in Java. i.e. we are unable to call the JCO call to a CRM function module from SCE.  The package for User defined classes "com.sap.sce.user" and the method inside it public boolean execute(fn_args args, Object obj) { ..... } has no option to make a FM call.
    Has anyone faced the similar requirement and has any resolution for this? 
    Thanks,
    Surya.

    Hi Eric,
    You sound quite familiar with the variant functions. I am also working on IPC-SCE
    variant functions for few years now.
    We have a situation where I am building some debug logs in one java variant function and want to display it to the web UI at some condition.
    Is there any object(like context etc.) that IPC server-side and Webapps share?
    I can write that log to a text file and read it from web ui ... but I wanna avoid that.
    Is there any other way you know of???
    Regards,
    Ruchika

  • How to access C/C++ functions in Java using existing .dll library

    Hi JNI Guru's,
    I am having well written API in C/C++.This C/C++ files are made into *.dll files.The api are working fine.
    I wan't access the C/C++ api functions in Java., just using System.LoadLibrary("*.dll").Is it possible.I kindly request you to suggest some examples and how to do this.
    Its Urgent !.
    Thanks and Regards,
    V K LAL

    In general you cannot simply access dlls that have already been written. The DLLs called using JNI must conform to JNI calling standards.
    This means you will probably have to write one or more "wrapper" dlls which a) provide the correct JNI interface, and b) call the existing dlls.
    There are some programs around that claim to be able to generate such wrappers. Try a google search for "wrapper", "jni", "generate".
    The JNI tutorial covers creating wrappers.

  • Calling c functions in java

    How do I call c functions from java?

    See http://java.sun.com/docs/books/tutorial/native1.1/index.html

  • Calling a SP or Function from Java receiving a geometry(MDSYS.SDO_GEOMETRY)

    Hi there,
    What I want to do is: calling a stored procedure OR function from Java with a String-variable as input and receiving a geometry (SDO_GEOMETRY).
    I’m facing currently the problem of calling a stored function on oracle 11g from Java using JPA (EclipseLink), Spring 2.5.6 returning an MDSYS.SDO_GEOMETRY object.
    I’ve tried to call a stored procedure with MDSYS.SDO_GEOMETRY as an output parameter instead, but with no success.
    The function’s signature looks like this:
    CREATE or REPLACE
    FUNCTION GET_GEO_BRD_FUNCTION(p_geo_brd_id IN VARCHAR2) RETURN MDSYS.SDO_GEOMETRY AS
    sdo_geom    MDSYS.SDO_GEOMETRY := null;
    BEGIN
    /* do some fancy stuff on the database side */
      SELECT sp_geom
        INTO sdo_geom
        FROM geo_brd WHERE id = p_geo_brd_id;
      RETURN sdo_geom;
    END;
    The calling code looks like this:
    MyClass extends JpaDaoSupport{
       /** logger */
       protected static final ILogger LOG = LogFactory.getLogger(MyClass.class);
        * {@inheritDoc}
        * @see com.example.MyClass#calculateGeometry(java.lang.String)
       @Override
       public JGeometry calculateGeometry(final String id) {
           JGeometry geometry = null;
           final JpaCallback action = new JpaCallback() {
                @Override
                public Object doInJpa(final EntityManager em) throws PersistenceException {
                   final Session session = JpaHelper.getEntityManager(em).getActiveSession();
                   final StoredFunctionCall functionCall = new StoredFunctionCall();
                   functionCall.setProcedureName("GET_GEO_BRD_FUNCTION");
                   functionCall.addNamedArgument("p_geo_brd_id");
                   functionCall.setResult("sdo_geom", Oracle.sql.STRUCT.class);
                   final ValueReadQuery query = new ValueReadQuery();
                   query.setCall(functionCall);
                   query.addArgument("p_geo_brd_id");
                   final ArrayList args = new ArrayList();
                   args.add("2e531e62-2105-4522-978a-ab8baf19e273");// hardcoded for test
                   final Object result = session.executeQuery(query, args);
                   return result;
        final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action);
        try {
           geometry = JGeometry.load(result);
        } catch (final SQLException e) {
           MyClass.LOG.error("Error loading JGeometry from STRUCT.", e);
           return null;
        return geometry;
    And when I execute the query I get the following error:
    Internal Exception: java.sql.SQLException: ORA-06550: Row 1, Column 13:
    PLS-00382: expression is of wrong type
    ORA-06550: Row 1, Column 7:
    PL/SQL: Statement ignored
    Error Code: 6550
    Call: BEGIN ? := GET_GEO_BRD_FUNCTION(p_geo_brd_id=>?); END;
         bind => [=> sdo_geom, 2e531e62-2105-4522-978a-ab8baf19e273]
    Query: ValueReadQuery()
    So I thought may be let's try it with a stored procedure instead...
    The procedure looks like this:
    CREATE or REPLACE
    PROCEDURE GET_GEO_BRD_PROCEDURE(p_geo_brd_id IN VARCHAR2, sdo_geom OUT MDSYS.SDO_GEOMETRY) AS
    BEGIN
    /* do some fancy stuff on the database side */
      SELECT sp_geom
        INTO sdo_geom
        from geo_brd where id = p_geo_brd_id;
    END;
    The calling Java code in case of the stored procedure looks like this (only the content of the JPACallback has changed):
    @Override
    public Object doInJpa(final EntityManager em) throws PersistenceException {
        final Session session = JpaHelper.getEntityManager(em).getActiveSession();
        final StoredProcedureCall spCall = new StoredProcedureCall();
        spCall.setProcedureName("GET_GEO_BRD_PROCEDURE");
        spCall.addNamedArgument("p_geo_brd_id", "p_geo_brd_id", String.class);
        spCall.addNamedOutputArgument("sdo_geom", "sdo_geom", OracleTypes.STRUCT);
        final ValueReadQuery query = new ValueReadQuery();
        query.setCall(spCall);
        query.addArgument("p_geo_brd_id"); // input
        final List args = new ArrayList();
        args.add("2e531e62-2105-4522-978a-ab8baf19e273");// hardcoded for test
        final Object result = session.executeQuery(query, args);
        return result;
    And when I execute the query I get the following error:
    java.sql.SQLException: ORA-06550: Row 1, Column 13:
    PLS-00306: wrong number or types of arguments in call to 'GET_GEO_BRD_PROCEDURE'
    ORA-06550: Row 1, Column 7:
    PL/SQL: Statement ignored
    So both exceptions look quite similar.
    I guess in both cases the exception description leads to the assumption, that the wrong type for the return value / output parameter is used…
    So - how can a receive a MDSYS_SDO_GEOMETRY object from a stored procedure or stored function in Java ?
    What is wrong in the Java code?
    Thank you in advance for any suggestions!
    Yours,
    Chris
    Edited by: user3938161 on 20.12.2011 07:46
    Edited by: user3938161 on Dec 20, 2011 8:06 AM: added variable declaration of JGeometry geometry in source code

    Thanks, that did the trick! ;-)
    Here is now the code for stored procedure and function for anybody else encountering the same troubles... (be aware of the parameter order and/or naming!)
    Code for stored functions:
    final JpaCallback action = new JpaCallback() {
      @Override
      public Object doInJpa(final EntityManager em) throws PersistenceException {
         final Session session = JpaHelper.getEntityManager(em).getActiveSession();
           * Using CallableStatement for stored functions
          STRUCT st = null;
          CallableStatement cs = null;
          final DatabaseLogin login = session.getLogin();
          final Connection _conn = (Connection) login.connectToDatasource(session.getDatasourceLogin().buildAccessor(), session);
          try {
             try {
                cs = _conn.prepareCall("{? = call GET_GEO_BRD_FUNCTION(?)}");
                cs.registerOutParameter(1, OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
                cs.setString(2, "2e531e62-2105-4522-978a-ab8baf19e273");//TODO: hardcoded for test
                cs.execute();
             } catch (final SQLException e) {
                MyClass.LOG.error("An exception occured calling the stored procedure", e);
             if (cs != null) {
                //reading geometry from the database
                try {
                   st = (STRUCT) cs.getObject(1);
                } catch (final SQLException e) {
                   MyClass.LOG.error("An exception occured converting the query result to oracle.sql.STRUCT", e);
          } finally {
             try {
                if (_conn != null && !_conn.isClosed()) {
                    _conn.close();
             } catch (final SQLException e) {
                MyClass.LOG.error("An exception occured on closing the database connection.", e);
          return st;
    final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action);
    The code for stored procedure solution:
    final JpaCallback action = new JpaCallback() {
      @Override
      public Object doInJpa(final EntityManager em) throws PersistenceException {
          final Session session = JpaHelper.getEntityManager(em).getActiveSession();
           * Using CallableStatement for stored procedure
          STRUCT st = null;
          CallableStatement cs = null;
          final DatabaseLogin login = session.getLogin();
          final Connection _conn = (Connection) login.connectToDatasource(session.getDatasourceLogin().buildAccessor(), session);
          try {
             try {
                cs = _conn.prepareCall("{call GET_GEO_BRD_PROCEDURE(?,?)}");
                cs.setString("p_geo_brd_id", "2e531e62-2105-4522-978a-ab8baf19e273");
                cs.registerOutParameter("sdo_geom", OracleTypes.STRUCT, "MDSYS.SDO_GEOMETRY");
                cs.execute();
              } catch (final SQLException e) {
                MyClass.LOG.error("An exception occured calling the stored procedure", e);
              if (cs != null) {
                //reading geometry from the database
                try {
                   st = (STRUCT) cs.getObject("sdo_geom");
                } catch (final SQLException e) {
                   MyClass.LOG.error("An exception occured converting the query result to oracle.sql.STRUCT", e);
           } finally {
              try {
                if (_conn != null && !_conn.isClosed()) {
                   _conn.close();
              } catch (final SQLException e) {
                MyClass.LOG.error("An exception occured on closing the database connection.", e);
            return st;
    final STRUCT result = (STRUCT) this.getJpaTemplate().execute(action);

  • Any Mod function in JAVA?

    I did not find 'MOD' function in the Math class. Is there any 'MOD' function in Java?
    Thanks!

    What is your MOD function?
    Does the %-operator do what you need or do you want a strict mathematical modulus that returns only positive values?

  • Can I use split function in PLD?

    Dear Experts,
    Can anyone show me if I have this value in a variable F_001 in PLD.
    012345-FAB
    How can I get the below output?  (Taking off the -FAB, by either using a split() function or equivalent)
    012345
    Much Thanks!
    Chinho

    Hi Chinho,
    ok, for example, IF you use add the last 4 Character only in CardCode(-FAB)
    F_001 -> CardCode = 012345-FAB
    or
    F_001 -> CardCode = 1000123456-FAB
    or
    F_001 -> CardCode = 987456814-ADM
    but you need to print the Value of CardCode is before last 4 Character Value .
    Output: 012345 or 1000123456 or 987456814
    Try this formula in PLD.
    Substring(F_001,0,(Length(F_001)-4))
    Regards,
    Madhan.

  • Why static is used before any function in java

    Sir/Madem
    I'm new in java. I have just started learning java.
    please tell me
    "why static is used before any function in java??????"
    I have searched on net and in soime bokks .But i was unable toget it. what is exact reson of using static in java.

    tandm-malviya wrote:
    Sir/Madem
    I'm new in java. I have just started learning java.
    please tell me
    "why static is used before any function in java??????"
    I have searched on net and in soime bokks .But i was unable toget it. what is exact reson of using static in java.It's actually seldom used in "real" applications. static associates the method with the class instead of an instance.
    Kaj

  • The troubles with creating SQL function in Java

    Hi!
    I use Oracle 10g and connect to it from Java application. I need in creating SQL functions from Java code.
    In Java I have:
    Statement stm = null; try{     stm = dbConnection.createStatement();     stm.executeUpdate( query ); }catch(SQLException ex){     throw ex; }finally{     try{ stm.close(); }catch(Exception ex){ stm.close(); } }
    And I'm passing the next SQL function:
    create or replace function get_me return number is
    result number;
    begin
    select 5 into result from dual;
    return result;
    end;
    This code is run successful, but I can't call this funtion, because it has status Invalid
    I'm looked the next error: PLS-00103: Encountered the symbol "" when expecting one of the following: . @ % ; is authid as cluster order using external character deterministic parallel_enable pipelined aggregate
    But I don't understand, What the matter? From Oracle Enterprise Manager I can create this function without problems. So, I wrote the wong Java code. Also, I can't find my error :(
    May be, do u have the some ideas?
    Thank you very much!

    Post the whole pl/sql code please.
    To run PL/SQL from within java you'll need callablestatement.
    [here |http://www.idevelopment.info/data/Programming/java/jdbc/PLSQL_and_JDBC/CallPLSQLFunc.java] an example : http://www.idevelopment.info/data/Programming/java/jdbc/PLSQL_and_JDBC/CallPLSQLFunc.java

Maybe you are looking for

  • Installing Latest Firefox on Windows XP Embedded gives error: "This application has failed to start because pdh.dll was not found"

    I'm trying to install the latest (standards-based) browser I can on on old Windows XP Embedded computer. The computer's hardware does not meet the "Recommended Hardware" of a Pentium 4 (it has a P3). I initially tried installing/running Firefox versi

  • PROBLEM FOR READ_TEXT in report

    Hi, I am reading texts using READ_TEXT in report. Here the problem is if the PO text doesn't contains any text(value)  then my report is not showing the output and if text contains value it's showing me output. where is the problem? Thanks in Advance

  • Inserting to a clob field using cx_Oracle via a stored procedure

    Hello, Does anyone have experience using cx_Oracle to call a stored procedure which inserts to a clob field? I have found examples of doing this via straight SQL but I was hoping it was possible to do this via a stored procedure call. Thanks for any

  • ARP cache not adding MAC address

    Hi, We have a network in the company where visitors\customers can connect their PCs to pick up a IP address & access the internet via our cluster of Checkpoint firewalls. The problem we are having is that whenever somebody with a Mac tries to use thi

  • HP Pavillion dv6646 notebook has no Sound

    My HP Pavilion dv6646 has no Audio Device Installed (according to the volume menu) after installing some updates. I've tried to roll back the computer to a point before the updates but it doesnot restore the audio. When trying to reinstall the factor