Java SOS

I have to read from an input file which is formatted different from what I am used to. it is as follows...
team name, 2
playera,4.3
playerb,8.2
team name,3
so on and so forth, I need to put them into arrays of each team, but I have literally no clue how, all help greatly appreciated. Also help is needed urgently, and more information needed just ask.

Welcome to the Sun forums. You need to study these two references.
http://java.sun.com/docs/books/tutorial/essential/io/
http://java.sun.com/j2se/1.5.0/docs/api/java/util/Scanner.html
You should create a class that represents an team and then use a collection of these teams.
Please note - marking your thread as 'urgent' implies that you think it more important than any other thread. Since it's not more important, using the word 'urgent' tends to have the opposite effect to the one intended.

Similar Messages

  • SOS!  How to study Java!

    SOS! How to study Java!

    Good place to start is with a good book!!!
    Ive heard "thinking in java" is a very good book....
    Also have heard its available online...

  • Core Java Issue in decimal division....SOS!!!!

    Hi People,
    I was just wondering the reason for below output generated in java.
    double d2 = 0.142;
    double d3 = d2/100;
    System.out.println(d3);
    Output = 0.0014199999999999998
    But if i do in calculator i get 0.00142
    double d2 = 0.152;
    double d3 = d2/100;
    System.out.println(d3);
    Output = 0.0015199999999999999
    But if i do in calculator i get 0.00152
    Any help is highly appreciated.

    939520 wrote:
    You also might want to read up on Java's  'strictfp' reserved word. I don't know if it will help and weather or not it applies to both float and double since I never used it.
    Setting  'strictfp' will make no difference. The Goldberg article explains the problem.
    If the OP is doing scientific or engineering work then the errors due to the fact that not all decimal values have a finite length binary representation will usually be small enough to be neglected. If the OP is working with money then, even though double has about 14 decimal places, it is unlikely to be acceptable.

  • I have a very bad problem with java I try many solution but all the solution failed

    Hello friends,
    My system  10.8.3 Macbook pro
    I try many solution in the 
    Hello friends,
    My system  10.8.3 Macbook Pro, I use Safari 6.0.3
    Java is not working.
    I try many solution in the  internet but nothing work with me , And I feel very sad
    One of the famous solution I try in this link: http://support.apple.com/kb/HT5559
      I download Java OS x 2013-002 and Java 7.17
    after that i do what is written here : http://support.apple.com/kb/HT5559 Also failed.
    Sometime I think to sell my new Macbook Pro because of this problem
    I hope that any one can help me ?
    Thank you
    Soso

    I check what java I have by this way: https://service.parachat.com/knowledgebase/211/How-do-I-check-which-Java-version -is-installed-on-my-Mac.html
    java version "1.6.0_43"
    Java(TM) SE Runtime Environment (build 1.6.0_43-b01-447-11M4203)
    Java HotSpot(TM) 64-Bit Server VM (build 20.14-b01-447, mixed mode)
    sos-macbook-pro:~ so$

  • ORA 01722 & NFE.....SOS!

    im constantly getting 2 errors on console (Solaris XManager)
    **java.sql.SQLException: ORA-01722: invalid number**
    **java.lang.NumberFormatException: For input string: "abc"**
    In my bean file theres a method calld 'FLoc()' in which
    im passing 5 parameteres (all strings) plus sessionID.
    in that method a method is called which is in another file
    called 'gsms()': there are SAME six parameters; all Strings
    also in that method, JDBC connectivity is done with
    procedure calls.
    That procedure contains 11 'IN' parameters & 2 'OUT'
    p pi_session_id                    IN      1          VARCHAR2,
                                  2          pi_B_p_M                    IN                VARCHAR2,
                                  3          pi_log_id                    IN                NUMBER,
                                  4          pi_B_p_loc                    IN                VARCHAR2,
                                  5          pi_ms_st                    IN                VARCHAR2,
                                  6          pi_s_re_time                    IN               VARCHAR,
                                  7          pi_s_re_flag                    IN               VARCHAR2,
                                  8          pi_s_re_text                    IN                VARCHAR2,
                                  9          pi_ap_st_id                    IN               NUMBER,
                                  10          pi_t_app                    IN               DATE,
                                  11          pi_s_er                    IN               VARCHAR2,
                                            po_err_code                    OUT               NUMBER,
                                            po_B_party_locn_details          OUT          Pkg_Refcur.ref_type)
    help needed !! SOS!!! this silly problem has been bugging me since a day!!! im not very comfortable with JDBC/Core Java concepts...
    i searched ORA error...it said some conversion problem.
    i couldnt understand please explain.

    Thanks dcminter for that. .....
    Got rid of that NumberFormatException but ORA 01722 error is still bugging me :)
    straight from the console ::
    at src.SInterface.dbstorage.gSM(dbstorage.java:212)
    at src.FLoc.FLocJBean.fLoc(FLocJBeanjava:146)
    at org.apache.jsp.src.FLoc.SLoc_jsp._jspService(SLoc_jsp.java:93)
    where could be the error???

  • ALERT: java/lang/ClassFormatError: Bad stack map.

    Hello friends.
    I need help. SOS.
    Where is wrong in this code?
    Problem is in comparision.
    Comenting this lines, all are ok.
            if(time1==time2)
                System.out.println("Equal");
            else
                System.out.println("Different");C�digo del Midlet:
    package borrame.pruebas;
    import java.util.Date;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Display;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    public class Prueba extends MIDlet implements CommandListener {
        Display display;
        Form mainForm;
        // Comandos para salir y volver a la pantalla principal.
        Command cmdSalir;
        public Prueba() {
            super();
            mainForm = new Form ("HelloMidp");
            cmdSalir = new Command("Salir", Command.EXIT,1);
            mainForm.addCommand(cmdSalir);
            mainForm.setCommandListener(this);
        protected void startApp() throws MIDletStateChangeException {
            display = Display.getDisplay(this);
            display.setCurrent (mainForm);
            long time1 = new Date().getTime();
            long time2 = new Date().getTime() +100;
            System.out.println("time1: " + time1);
            System.out.println("time2: " + time2);
            System.out.println("time1 + time2 =" + (time1 + time2));
            if(time1==time2)
                System.out.println("Equal");
            else
                System.out.println("Different");
        protected void pauseApp() {
            // TODO Auto-generated method stub
        protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
            // TODO Auto-generated method stub
        public void commandAction(Command c, Displayable d) {
            if (c == cmdSalir) { // Selecciono salir de la aplicacion
                try {
                    destroyApp(false);
                } catch (MIDletStateChangeException e) {
                    e.printStackTrace();
                notifyDestroyed();
    }Output console:
    Warning: Cannot convert string "-b&h-lucida-medium-r-normal-sans-*-140-*-*-p-*-iso8859-1" to type FontStruct
    Running with storage root DefaultColorPhone
    ALERT: java/lang/ClassFormatError: Bad stack map.
    Method............: b7d29990 'com/sun/midp/midlet/MIDletState.createMIDlet (static)'
    Stack Chunk.......: b783d300
    Frame Pointer.....: b783d3a4
    Current IP........: b7da5669 = b7da565b + offset 14
    Previous Frame....: b783d36c
    Previous IP.......: b7d87f44 (offset 52)
    Frame size........: 7 (1 arguments, 6 local variables)
    Argument[0].......: b783cad0
    Local[1]..........: b78b35c8
    Local[2]..........: b7d87f41
    Local[3]..........: b783cc38
    Local[4]..........: b7d29788
    Local[5]..........: b78b355c
    Local[6]..........: 0
    Operand[1]........: b783cad0
    Method............: b7d16390 'com/sun/midp/midlet/Scheduler.schedule (virtual)'
    Stack Chunk.......: b783d300
    Frame Pointer.....: b783d36c
    Current IP........: b7d87f44 = b7d87f10 + offset 52
    Previous Frame....: b783d338
    Previous IP.......: b7d92b05 (offset 28)
    Frame size........: 7 (2 arguments, 5 local variables)
    Argument[0].......: b783cd14
    Argument[1].......: b783c460
    Local[2]..........: b78b20c4
    Local[3]..........: b78b3594
    Local[4]..........: b7d92b01
    Local[5]..........: b78b35a8
    Local[6]..........: b7d162b0
    Operand[1]........: b783cd14
    Method............: b7d1e084 'com/sun/midp/main/Main.runLocalClass (static)'
    Stack Chunk.......: b783d300
    Frame Pointer.....: b783d338
    Current IP........: b7d92b05 = b7d92ae9 + offset 28
    Previous Frame....: b783d314
    Previous IP.......: b7d9257c (offset 116)
    Frame size........: 3 (1 arguments, 2 local variables)
    Argument[0].......: b783d1bc
    Local[1]..........: b783c460
    Local[2]..........: b78b3570
    Method............: b7d1dfe4 'com/sun/midp/main/Main.main (static)'
    Stack Chunk.......: b783d300
    Frame Pointer.....: b783d314
    Current IP........: b7d9257c = b7d92508 + offset 116
    Previous Frame....: 0
    Previous IP.......: 1
    Frame size........: 3 (1 arguments, 2 local variables)
    Argument[0].......: b783d5ec
    Local[1]..........: b783d1bc
    Local[2]..........: b783cb24
    VM status:
    Instruction pointer.: b7da5669 (offset within invoking method: 14)
    Next instruction....: 0x4c
    Frame pointer.......: b783d3a4
    Local pointer.......: b783d388
    Stack size..........: 128; sp: b783d3bc; ranges: b783d308-b783d508;
    Contents of the current stack frame:
        b783d388: b783cad0 (lp)
        b783d38c: b78b35c8
        b783d390: b7d87f41
        b783d394: b783cc38
        b783d398: b7d29788
        b783d39c: b78b355c
        b783d3a0: 0
        b783d3a4: b783d36c (fp)
        b783d3a8: b7d87f44
        b783d3ac: b783d384
        b783d3b0: b7d29990
        b783d3b4: b783d300
        b783d3b8: 0 (end of frame)
        b783d3bc: b783cad0 (sp)
    Execution stack contains 184 items:
    b783d5ec
    b783d1bc
    b783cb24
    0
    1
    b78b3560
    b7d1dfe4
    b783d300
    0
    b783d1bc
    b783c460
    b78b3570
    b783d314
    b7d9257c
    b783d328
    b7d1e084
    b783d300
    0
    b783cd14
    b783c460
    b78b20c4
    b78b3594
    b7d92b01
    b78b35a8
    b7d162b0
    b783d338
    b7d92b05
    b783d34c
    b7d16390
    b783d300
    0
    b783cd14
    b783cad0
    b78b35c8
    b7d87f41
    b783cc38
    b7d29788
    b78b355c
    0
    b783d36c
    b7d87f44
    b783d384
    b7d29990
    b783d300
    0
    b783cad0
    Execution completed.
    717374 bytecodes executed
    5 thread switches
    742 classes in the system (including system classes)
    3720 dynamic objects allocated (102340 bytes)
    2 garbage collections (88196 bytes collected)
    Execution completed.
    717374 bytecodes executed
    5 thread switches
    742 classes in the system (including system classes)
    3720 dynamic objects allocated (102340 bytes)
    2 garbage collections (88196 bytes collected)

    My enviroment:
    Linux Gentoo.
    Sun JDK 1.4.2.10
    eclipse 3.2 WTP 1.5
    eclipseme 1.5.5
    Midlet config:
    MIDlet-Version: 1.0
    MicroEdition-Configuration: CLDC-1.0
    MicroEdition-Profile: MIDP-1.0
    WTK 2.2
    In last test, i'm using ktoolbar directly to build and execute midlet and all go ok.
    So, My code is not problem.
    I suppose that eclipseme corrupt my classes in build process.
    SOLUTION:
    My radical solution. I use eclipse without eclipseme, and i use ktoolbar to build, run, package, etc...
    Thank's

  • Socket connection between Java and C

    I want to establish socket connection between Java client and C server (on Unix). Can anybody tell how to do it? Will the socket created in client be available in server. I tried out but there was no response from the server.

    We too can't connect the daemon server written by "c". The phenomena is below.
    << Execution of this Question1.class >> ---------------------------------------
    [kazuyuki@CryptOne tmp]$ java Question1 E 1.2.3.4 MFrame.java 195.211.1.1 15021
    << Output message >> ----------------------------------------------------------
    Quetion1 : flg_ = E
    Quetion1 : key_ = 1.2.3.4
    Quetion1 : fn_ = MFrame.java
    Quetion1 : adr_ = CryptOne.localhost/195.211.1.1
    Quetion1 : port_ = 15021
    java.net.ConnectException: Connection refused
         at java.net.PlainSocketImpl.socketConnect(Native Method)
         at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:350)
         at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:137)
         at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:124)
         at java.net.Socket.<init>(Socket.java:268)
         at java.net.Socket.<init>(Socket.java:122)
         at Question1.UPLOAD(Question1.java:65)
         at Question1.main(Question1.java:155)
    << Question >> ----------------------------------------------------------------
    Why the event "java.net.ConnectException: Connection refused" has occured ?
    The server to connect from Question1 can accept the connection request from
    the client program coded by "c" program. We have written down the daemon server
    program by "c" code tcp/ip socket functions (socket, bind, listen, accept).
    Security manager admits the access from this Question1.class, we have checked.
    Would you like please answer this Connction refuse occurrence ?
                                                                     2002.05.18 11:50:00.0(JST)
                                                                     K.Masuda
    << Java client code>> -------------------------------------------------
         (c)Copyright     All rights reserved.
              K.Masuda     2002.05.18
                   << Question1.java >>
    import     java.lang.String;
    import     java.io.InputStream;
    import     java.io.OutputStream;
    import     java.io.DataInputStream;
    import     java.io.DataOutputStream;
    import     java.io.FileInputStream;
    import     java.io.FileOutputStream;
    import     java.io.IOException;
    import     java.io.FileNotFoundException;
    import     java.net.Socket;
    import     java.net.InetAddress;
    import     java.net.UnknownHostException;
    import     java.net.ConnectException;
    import     java.net.NoRouteToHostException;
    class Question1 {
         char               flg_;
         String               key_;
         String               fn_;
         InetAddress          adr_;
         int                    port_;
         Socket               sock_;
         Question1(
              char          flg,
              String          key,
              String          fn,
              String          adr,
              int               port
              flg_     = flg;     
              key_     = key;
              fn_          = fn;
              try{
                   adr_     = InetAddress.getByName( adr );
              catch( UnknownHostException e ){
                   e.printStackTrace();
              port_     = port;
    System.out.println( "Quetion1 : flg_ = " + flg_ );
    System.out.println( "Quetion1 : key_ = " + key_ );
    System.out.println( "Quetion1 : fn_ = " + fn_ );
    System.out.println( "Quetion1 : adr_ = " + adr_ );
    System.out.println( "Quetion1 : port_ = " + port_ );
         public void UPLOAD(
              try{
                   sock_     = new Socket( adr_, port_ );
                   UpLoad();
                   DnLoad();
                   sock_.close();
              catch( UnknownHostException e ){
                   e.printStackTrace();
              catch( ConnectException e ){
                   e.printStackTrace();
              catch( NoRouteToHostException e ){
                   e.printStackTrace();
              catch( IOException e ){
                   e.printStackTrace();
         public void UpLoad(
              byte[]                         buf          = new byte[ 512 ];
              int                              rlen;
              int                              wlen;
              try {
                   OutputStream          sos          = sock_.getOutputStream();
                   FileInputStream          fis          = new FileInputStream( fn_ );
                   DataInputStream          dis          = new DataInputStream( fis );
                   DataOutputStream     dos          = new DataOutputStream( sos );
                   while( ( rlen =     dis.read( buf, 0, buf.length ) ) >= 0 ){
                        dos.write( buf, 0, rlen );
                   dis.close();
                   dos.close();
                   fis.close();
                   sos.close();
              catch( IOException e ){
                   e.printStackTrace();
         public void DnLoad(
              byte[]                         buf          = new byte[ 512 ];
              int                              rlen;
              int                              wlen;
              try {
                   InputStream               sis          = sock_.getInputStream();
                   FileOutputStream     fos          = new FileOutputStream( fn_ + ".cry" );
                   DataInputStream          dis          = new DataInputStream( sis );
                   DataOutputStream     dos          = new DataOutputStream( fos );
                   while( ( rlen =     dis.read( buf, 0, buf.length ) ) >= 0 ){
                        dos.write( buf, 0, rlen );
                   dis.close();
                   dos.close();
                   fos.close();
                   sis.close();
              catch( IOException e ){
                   e.printStackTrace();
         public static void main(
              String[] args
              char[]     chrs     = ( new String( args[ 0 ] ) ).toCharArray();
              Question1     clnt     = new Question1(
                                                                     // E or D
                                            chrs[ 0 ],
                                            args[ 1 ],               // key string
                                            args[ 2 ],               // file to be processed
                                            args[ 3 ],               // IP address
                                                                     // port
                                            Integer.parseInt( args[ 4 ] )
              clnt.UPLOAD();
    }

  • Using Servlets in java studio creator

    Hello, anyone can tell me how can i use a servlet in java studio creator, due the file is in .java i dont know how to use it, here is an example i want to add to my proyect:
    and other question is how can i make to work?
    * Sean C. Sullivan
    * June 2003
    * URL: http://www.seansullivan.com/
    package pdfservlet;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.util.*;
    import java.io.ByteArrayOutputStream;
    import java.io.PrintWriter;
    // import the iText packages
    import com.lowagie.text.*;
    import com.lowagie.text.pdf.*;
    * a servlet that will generate a PDF document
    * and send the document to the client via the
    * ServletOutputStream
    * @author Sean C. Sullivan
    public class PDFServlet extends HttpServlet
         public PDFServlet()
              super();
         * we implement doGet so that this servlet will process all
         * HTTP GET requests
         * @param req HTTP request object
         * @param resp HTTP response object
         public void doGet(HttpServletRequest req, HttpServletResponse resp)
              throws javax.servlet.ServletException, java.io.IOException
              DocumentException ex = null;
              ByteArrayOutputStream baosPDF = null;
              try
                   baosPDF = generatePDFDocumentBytes(req, this.getServletContext());
                   StringBuffer sbFilename = new StringBuffer();
                   sbFilename.append("filename_");
                   sbFilename.append(System.currentTimeMillis());
                   sbFilename.append(".pdf");
                   // Note:
                   // It is important to set the HTTP response headers
                   // before writing data to the servlet's OutputStream
                   // Read the HTTP 1.1 specification for full details
                   // about the Cache-Control header
                   resp.setHeader("Cache-Control", "max-age=30");
                   resp.setContentType("application/pdf");
                   // The Content-disposition header is explained
                   // in RFC 2183
                   // http://www.ietf.org/rfc/rfc2183.txt
                   // The Content-disposition value will be in one of
                   // two forms:
                   // 1) inline; filename=foobar.pdf
                   // 2) attachment; filename=foobar.pdf
                   // In this servlet, we use "inline"
                   StringBuffer sbContentDispValue = new StringBuffer();
                   sbContentDispValue.append("inline");
                   sbContentDispValue.append("; filename=");
                   sbContentDispValue.append(sbFilename);
                   resp.setHeader(
                        "Content-disposition",
                        sbContentDispValue.toString());
                   resp.setContentLength(baosPDF.size());
                   ServletOutputStream sos;
                   sos = resp.getOutputStream();
                   baosPDF.writeTo(sos);
                   sos.flush();
              catch (DocumentException dex)
                   resp.setContentType("text/html");
                   PrintWriter writer = resp.getWriter();
                   writer.println(
                             this.getClass().getName()
                             + " caught an exception: "
                             + dex.getClass().getName()
                             + "<br>");
                   writer.println("<pre>");
                   dex.printStackTrace(writer);
                   writer.println("</pre>");
              finally
                   if (baosPDF != null)
                        baosPDF.reset();
         * @param req must be non-null
         * @return a non-null output stream. The output stream contains
         * the bytes for the PDF document
         * @throws DocumentException
         protected ByteArrayOutputStream generatePDFDocumentBytes(
              final HttpServletRequest req,
              final ServletContext ctx)
              throws DocumentException
              Document doc = new Document();
              ByteArrayOutputStream baosPDF = new ByteArrayOutputStream();
              PdfWriter docWriter = null;
              try
                   docWriter = PdfWriter.getInstance(doc, baosPDF);
                   doc.addAuthor(this.getClass().getName());
                   doc.addCreationDate();
                   doc.addProducer();
                   doc.addCreator(this.getClass().getName());
                   doc.addTitle("This is a title.");
                   doc.addKeywords("pdf, itext, Java, open source, http");
                   doc.setPageSize(PageSize.LETTER);
                   HeaderFooter footer = new HeaderFooter(
                                       new Phrase("This is a footer."),
                                       false);
                   doc.setFooter(footer);
                   doc.open();
                   doc.add(new Paragraph(
                                  "This document was created by a class named: "
                                  + this.getClass().getName()));
                   doc.add(new Paragraph(
                                  "This document was created on "
                                  + new java.util.Date()));
                   String strServerInfo = ctx.getServerInfo();
                   if (strServerInfo != null)
                        doc.add(new Paragraph(
                                  "Servlet engine: " + strServerInfo));
                   doc.add(new Paragraph(
                                  "This is a multi-page document."));
                   doc.add( makeGeneralRequestDetailsElement(req) );
                   doc.newPage();
                   doc.add( makeHTTPHeaderInfoElement(req) );
                   doc.newPage();
                   doc.add( makeHTTPParameterInfoElement(req) );
              catch (DocumentException dex)
                   baosPDF.reset();
                   throw dex;
              finally
                   if (doc != null)
                        doc.close();
                   if (docWriter != null)
                        docWriter.close();
              if (baosPDF.size() < 1)
                   throw new DocumentException(
                        "document has "
                        + baosPDF.size()
                        + " bytes");          
              return baosPDF;
         * @param req HTTP request object
         * @return an iText Element object
         protected Element makeHTTPHeaderInfoElement(final HttpServletRequest req)
              Map mapHeaders = new java.util.TreeMap();
              Enumeration enumHeaderNames = req.getHeaderNames();
              while (enumHeaderNames.hasMoreElements())
                   String strHeaderName = (String) enumHeaderNames.nextElement();
                   String strHeaderValue = req.getHeader(strHeaderName);
                   if (strHeaderValue == null)
                        strHeaderValue = "";
                   mapHeaders.put(strHeaderName, strHeaderValue);
              Table tab = makeTableFromMap(
                        "HTTP header name",
                        "HTTP header value",
                        mapHeaders);
              return (Element) tab;
         * @param req HTTP request object
         * @return an iText Element object
         protected Element makeGeneralRequestDetailsElement(
                                  final HttpServletRequest req)
              Map mapRequestDetails = new TreeMap();
              mapRequestDetails.put("Scheme", req.getScheme());
              mapRequestDetails.put("HTTP method", req.getMethod());
              mapRequestDetails.put("AuthType", req.getAuthType());
              mapRequestDetails.put("QueryString", req.getQueryString());
              mapRequestDetails.put("ContextPath", req.getContextPath());
              mapRequestDetails.put("Request URI", req.getRequestURI());
              mapRequestDetails.put("Protocol", req.getProtocol());
              mapRequestDetails.put("Remote address", req.getRemoteAddr());
              mapRequestDetails.put("Remote host", req.getRemoteHost());
              mapRequestDetails.put("Server name", req.getServerName());
              mapRequestDetails.put("Server port", "" + req.getServerPort());
              mapRequestDetails.put("Preferred locale", req.getLocale().toString());
              Table tab = null;
              tab = makeTableFromMap(
                                  "Request info",
                                  "Value",
                                  mapRequestDetails);
              return (Element) tab;
         * @param req HTTP request object
         * @return an iText Element object
         protected Element makeHTTPParameterInfoElement(
                             final HttpServletRequest req)
              Map mapParameters = null;
              mapParameters = new java.util.TreeMap(req.getParameterMap());
              Table tab = null;
              tab = makeTableFromMap(
                        "HTTP parameter name",
                        "HTTP parameter value",
                        mapParameters);
              return (Element) tab;
         * @param firstColumnTitle
         * @param secondColumnTitle
         * @param m map containing the data for column 1 and column 2
         * @return an iText Table
         private static Table makeTableFromMap(
                   final String firstColumnTitle,
                   final String secondColumnTitle,
                   final java.util.Map m)
              Table tab = null;
              try
                   tab = new Table(2 /* columns */);
              catch (BadElementException ex)
                   throw new RuntimeException(ex);
              tab.setBorderWidth(1.0f);
              tab.setPadding(5);
              tab.setSpacing(5);
              tab.addCell(new Cell(firstColumnTitle));
              tab.addCell(new Cell(secondColumnTitle));
              tab.endHeaders();
              if (m.keySet().size() == 0)
                   Cell c = new Cell("none");
                   c.setColspan(tab.columns());
                   tab.addCell(c);
              else
                   Iterator iter = m.keySet().iterator();
                   while (iter.hasNext())
                        String strName = (String) iter.next();
                        Object value = m.get(strName);
                        String strValue = null;
                        if (value == null)
                             strValue = "";
                        else if (value instanceof String[])
                             String[] aValues = (String[]) value;
                             strValue = aValues[0];
                        else
                             strValue = value.toString();
                        tab.addCell(new Cell(strName));
                        tab.addCell(new Cell(strValue));
              return tab;
    }

    Hi, i've done all described in the posts, but i
    don't know how to call the servlet, using the web
    browser, and more, how can i call the servlet frrom
    a button action? or hyperlink?
    nks for the helpOk, I am not sure what you are trying to do. For these events you can
    use the SessionBean. What do you want the servlet to do that the session bean can't?
    I use the sessionbean because I don't know how to receive or respond to xmlhttpreq messages directly in my sessionbean. If you just need the standard http req/resp it doesn't seem like a servlet is needed.

  • How to eliminate ^M in files thru java program

    Hi guys,
    SOS!!!
    I need to know how to eliminate ^M from files using a java program. This question was posted many times, but no one answered the question. Does anyone know the answer. Post the answer if anyone knows it.
    Thanks guys n gals.

    You need to create new strings with the /r stripped off
    /** Takes a string, and replaces the replace text with new text.
    * @param str String to replace into
    * @param pattern Pattern of text to replace.
    * @param replace What to replace it with.
    * @return str with the replace text replaced with the new text.
    protected static String replace(String str,String pattern, String replace) {
    int s = 0;
    int e = 0;
    StringBuffer result = new StringBuffer();
    while ((e = str.indexOf(pattern, s)) >= 0) {
    result.append(str.substring(s, e));
    result.append(replace);
    s = e+pattern.length();
    result.append(str.substring(s));
    return result.toString();
    }

  • Oracle Calendar - UnsatisfiedLinkError: no csdkjni in java.library.path

    Hi, all.
    I deployed my test calendar application developed using Jdeveloper 10.1.3.0 (on Windows XP) to the Oracle 10.1.3. AS on a linux server, but the CalendarServer in on another installation (Collaboration Suite 10.1.2) on the same linux server.
    When I try to executed the code that calls the calendar server I get this error:
    500 Internal Server Error
    javax.faces.el.EvaluationException: java.lang.UnsatisfiedLinkError: no csdkjni in java.library.path
    I set the LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:$ORACLE_HOME/ocal/lib on the collaboration suite 10.1.2 installation.
    When I try to run the code on my Jdeveloper I get the same error:
    java.lang.UnsatisfiedLinkError: no csdkjni in java.library.path
    In my windows machine I create a folder where I put the dll's and jar files that came from the collaboration suite windows installation, but I get always the same error
    This is the code:
    try
    Api.init("calendar.ini", "calendar.log");
    catch(Api.StatusException e)
    System.out.println("init returned status'" + e.getMessage() + "'");
    System.exit (1);
    Is my approach correct? Because if i'm developing on Windows and I need dll's files to connect to the calendar server on linux, but when I deploy the application to the linux server those dll's are useless and cannot be used. So am I missing something here? Do I need anything else to get this to work?
    Best Regards,
    Rui

    1. Use 1 and only 1 of classes12.zip and ojbc14.jar; they have different versions of the same classes in them.
    2. The Oracle OCI driver for JDBC uses .dll files or .so files from the Oracle client installation (as well as Oracle network configuration files, I think); most people use the thin driver instead to avoid this problem.
    To use the thin driver, change your url, see here for details:
    http://www.oracle.com/technology/tech/java/sqlj_jdbc/htdocs/jdbc_faq.htm#05_00
    To stay with the OCI driver (not recommended), you need to have the appropriate Oracle client installation (or at least get the dlls or sos), and I think set additional environment variables, such as ORACLE_HOME and possibly LD_LIBRARY_PATH. I don't do this myself, so I can't give much more advice.

  • Java Servlet BUG (Possibly)-Servlet classname replaces retrieved doc name

    I created a test servlet (TestServlet.java) which reads data from a file which could be pdf/doc/xls/zip etc and presents the file to the user for download. When the user clicks on the save option to save the file the default name before the file extension of the file in the save dialog box is always TestServlet. i.e. If the file being downloaded is BEA.doc the default name in the save dialog box is TestServlet.doc
    The contents of the file(data in the file) are correct but the default name should be BEA.doc and not TestServlet.doc. I get the same result if the file is a pdf/xls or any other file type which is being downloaded.
    We tested this in BEA Weblogic 8.1 and Tomcat and get the same results both places so this issue is not application server specific and seems like a bug to us.
    The TestServlet.java file is below
    package com.test;
    import java.io.*;
    import java.util.*;
    import javax.servlet.http.*;
    public class TestServlet  extends HttpServlet
        private String fileName = "c:/BEA.doc";
        private FileInputStream  rd;
        private ByteArrayOutputStream wr;
        byte[] buf = new byte[8192];    //buffer size
        byte[] fileData;
        public void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
            doPost(request,response);     
        public void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, java.io.IOException
            int count = 0;
            try
                File theFile = new File(fileName);
                if (theFile.exists())
                    try
                        rd = new FileInputStream(fileName);
                        wr = new ByteArrayOutputStream();
                        while ((count = rd.read(buf)) > -1)
                            wr.write(buf, 0, count);
                        rd.close();                   
                        fileData = wr.toByteArray();
                        response.setContentType("application/msword");
                        OutputStream sos = response.getOutputStream();
                        sos.write(fileData);
                        sos.flush();
                        sos.close();                  
                    catch(Exception ex)
                        System.out.println(ex.getMessage());
                else
                    response.setContentType("text");
                    response.getWriter().write("no data");
            catch (Exception e)
                e.printStackTrace();       
    } I get the same results. i.e. The name of the document downloaded by the servlet is TestServlet.doc instead of BEA.doc which is what I have in c:\BEA.doc.

    The web browser downloading this knows nothing about the file you are loading from disk and sending via the servlet. All it knows is that it requested via Http on the url TestServlet, and is getting something in return.
    A quick google pulled up this link: http://builder.com.com/5100-6370-1027645.html
    You might try this:
    response.setHeader("Content-Disposition","inline;filename=\"BEA.doc\"");
    good luck,
    evnafets

  • Java.io.EOFException in Object file transfer

    Greetings,
    I am having a problem sending a file across a network. At one point it was working, however I am not sure where along the way it became broken.
    Stack Trace:
    java.io.EOFException
    at java.io.ObjectInputStream$PeekInputStream.readFully(Unknown Source)
    at java.io.ObjectInputStream$BlockDataInputStream.readShort(Unknown Sour
    ce)
    at java.io.ObjectInputStream.readStreamHeader(Unknown Source)
    at java.io.ObjectInputStream.<init>(Unknown Source)
    at WBServer.unpackVectors(WBServer.java:283)
    at fileListener.run(WBServer.java:374)
        public void getWBContent(String hid) throws java.rmi.RemoteException //<- Send all object vectors and relevant integers...
            setPageNum(pageCount-1);
            HID=hid;
            packVectors(null);
            new Thread() {
                public void run(){
                   try{javax.swing.SwingUtilities.invokeLater(
                   new Runnable(){
                       public void run(){
                            try{ //Yes...
                                java.net.Socket s = new java.net.Socket(HID, 1113); //<- Make a network port
                                java.io.BufferedWriter sos = new java.io.BufferedWriter(new java.io.OutputStreamWriter(s.getOutputStream())); //<-Open a stream
                                sos.write("vectordata.dat"); //<-Send the name of the file
                                sos.close(); //<- Close the stream
                                s.close(); //<- Close the port
                                String anchor = getClass().getResource("WBServer.class").getPath();
                                java.net.Socket ns = new java.net.Socket(HID, 1113); //<- Open a new port to the same place
                                java.io.FileInputStream fio = new java.io.FileInputStream(anchor.substring(0, anchor.lastIndexOf('/')+1)+"vectordata.dat"); //<- Open the file to stream
                                //java.io.DataInputStream dia = new java.io.DataInputStream(fio); //<- Open the stream to read
                                java.io.BufferedInputStream bia = new java.io.BufferedInputStream(fio);
                                java.io.BufferedOutputStream boa = new java.io.BufferedOutputStream(ns.getOutputStream());//<- Open the data stream for the port
                                int read=0; //<- Byte Read Counter
                                byte[] fbuffer = new byte[1024]; //<- Byte Read Buffer
                                boolean EOF=false;
                                while(!EOF){ //<- Until we reach the end of the stream...
                                    try{read=bia.read(fbuffer);
                                    boa.write(fbuffer, 0, read);} //<- ...send the number of bytes stored in the buffer at the time.
                                    catch(java.io.EOFException e){ EOF=true;}
                                boa.flush(); //<- Make sure the stream is cleared
                                boa.close(); //<- Close the port's stream
                                bia.close(); //<- Close the reading stream
                                fio.close(); //<- Close the file's stream
                                ns.close(); //<- Close the port...
                            catch(Exception e)
                            {SimpleFormatter sf = new SimpleFormatter();
                             LogRecord tempLog = new LogRecord(Level.WARNING, "File Send Error: "+e.toString());
                             sf.format(tempLog);
                             logFile.publish(tempLog);}
                    catch(Exception e)
                    {SimpleFormatter sf = new SimpleFormatter();
                     LogRecord tempLog = new LogRecord(Level.WARNING, "Error running getWBContent() send file thread: "+e.toString());
                     sf.format(tempLog);
                     logFile.publish(tempLog);}
                }}.start();
        public void packVectors(String filePath) {   //This function writes all the objects in memory to a file for transport.
            String anchor = getClass().getResource("WBServer.class").getPath();
            if(filePath==null){filePath=anchor.substring(0, anchor.lastIndexOf('/')+1)+"data/vectordata.dat";}
            System.out.println("From packVectors(): "+filePath);
            java.io.File ovFile = new java.io.File(filePath); //Setup out data file
            try{if(!ovFile.exists()){ovFile.createNewFile();}else{ovFile.delete(); ovFile.createNewFile();} //If it's not there...make one. If it is, delete it and make a new one.
            java.io.ObjectOutputStream oojStream = new java.io.ObjectOutputStream(new java.io.FileOutputStream(ovFile)); //Ready the writer for writingness.
            oojStream.writeObject(PageHolder); //Pages to file...
            oojStream.writeObject(ImgPage); //Images for the Pages to file...
            oojStream.writeObject(WBStack); //Current object stack to file...
            oojStream.writeInt(objCount); //Current object count to file...
            oojStream.writeInt(pageCount); //Current page count to file...
            oojStream.writeInt(pageCount-1); //Current page number to file...
            oojStream.flush(); //<-Commit final write operations...
            oojStream.close();} //<- Close the file...
            catch(Exception e)
            {SimpleFormatter s = new SimpleFormatter();
             LogRecord tempLog = new LogRecord(Level.WARNING, "Persistence save error: "+e.toString());
             s.format(tempLog);
             e.printStackTrace();
             logFile.publish(tempLog);}
        public void unpackVectors(String filePath) {   //This function reads objects from a file that was previously written by packVectors().
            String anchor = getClass().getResource("WBServer.class").getPath();
            if(filePath==null){filePath=anchor.substring(0, anchor.lastIndexOf('/')+1)+"data/vectordata.dat";}
            System.out.println("From unpackVectors(): "+filePath);
            java.io.File ivFile = new java.io.File(filePath); //Setup the file to read from.
            try{if(!ivFile.exists()){ //If the file doesn't exist, we're screwed...
                SimpleFormatter s = new SimpleFormatter();
                LogRecord tempLog = new LogRecord(Level.WARNING, "Persistence load error: File vectordata.dat does not exist!");
                s.format(tempLog);
                logFile.publish(tempLog);
            }else{
                java.io.ObjectInputStream iojStream = new java.io.ObjectInputStream(new java.io.FileInputStream(ivFile)); //Ready the reader for readingness...
                PageHolder = (java.util.Vector)iojStream.readObject(); //Pages from file...
                ImgPage = (java.util.Vector)iojStream.readObject(); //images for Pages from file...
                WBStack = (java.util.Vector)iojStream.readObject(); //Current object stack from file...
                objCount = iojStream.readInt(); //Current object count from file...
                pageCount = iojStream.readInt(); //Current number of pages from file...
                pageNum = iojStream.readInt();//iojStream.readInt(); //Current page number from file...
                iojStream.close();}} //Close the file...
            catch(Exception e)// We screwed up somewhere.....
            {SimpleFormatter s = new SimpleFormatter();
             LogRecord tempLog = new LogRecord(Level.WARNING, "Persistence load error: "+e.toString());
             s.format(tempLog);
             e.printStackTrace();
             logFile.publish(tempLog);}
    class fileListener extends Thread {
        public fileListener(WBServer wb) //<-Constructor
            try{ms = new java.net.ServerSocket(1113);} //<- Listener socket
            catch(Exception e){e.toString();}
            server = wb; //<- Referencial variable back to the server
        public fileListener(WBServer wb, int port) //<- Constructor with port
            try{ms = new java.net.ServerSocket(port);} //<- Listener socket
            catch(Exception e){e.toString();}
            server = wb; //<- Referencial variable back to the server
        public void run() {
            String filepath; //<- Holder for file path operations...
            while(!disconnect) {
                try{java.net.Socket cs = ms.accept(); //<- Accept incoming request.
                server.fileStat = 1;
                java.io.BufferedReader str = new java.io.BufferedReader(new java.io.InputStreamReader(cs.getInputStream())); //<- Open communications with client
                String checkStr = str.readLine(); //<- Grab the file name from the client
                System.out.println(checkStr);
                String anchor = getClass().getResource("fileListener.class").getPath();
                if(checkStr.equalsIgnoreCase("vectordata.dat"))
                {filepath=anchor.substring(0, anchor.lastIndexOf('/')+1)+"data/"+checkStr;}
                else{filepath=anchor.substring(0, anchor.lastIndexOf('/')+1)+"scans/"+checkStr;}
                System.out.println(filepath);
                str.close(); //<- Close communications with client
                cs.close(); //<- Close socket
                //System.out.println("Recieved File Name: "+filepath);//Debugging
                java.io.File inFile = new java.io.File(filepath); //<- Make a file in memory on the host computer with the specified name.
                inFile.createNewFile(); //<- Create an empty file of that name within the local file system
                java.net.Socket ds = ms.accept(); //<- Accept incoming request
                java.io.FileOutputStream fos = new java.io.FileOutputStream(inFile); //<- Open file stream for writing...
                java.io.BufferedInputStream bis = new java.io.BufferedInputStream(ds.getInputStream()); //<- Open communications with client for data/
                byte[] fbuffer = new byte[1024]; //<- Byte read buffer
                int read=0; //<- Byte read counter
                server.fileStat = 2;
                while((read=bis.read(fbuffer))!=-1){ //<-Until we reach the end of the stream...
                    fos.write(fbuffer, 0, read); System.out.print(read+":");}// <- ...write the buffer to the file.
                fos.flush(); //<- Clear the file stream
                fos.close(); //<- Close the file stream
                bis.close(); //<- Close the data stream from the client
                if(checkStr.equalsIgnoreCase("vectordata.dat"))
                {server.fileStat = 3; // ...otherwise, we show loading...
                 server.unpackVectors(null);
                 server.sendRefresh(true);
                 server.fileStat=0;}
                else //If it's the sych data, unpack it and load the data
                {server.fileStat = 3; // ...otherwise, we show loading...
                 server.passImage(inFile); //<-Load the file into the image vector...
                 server.sendRefresh(true); //<- Ensure that the client updates properly
                 server.fileStat=0;}
                ds.close(); //<- Close the client socket
                catch(Exception e){e.toString();}
            //System.out.println("Listener Shutdown");//Debugging
            try{ms.close();} catch(Exception e){e.toString();} //<- Close the listening socket
        public boolean disconnect = false; //<- Flag for killing the "file server" prematurely
        private static WBServer server; //<- Referencial variable to the whiteboard server
        private java.net.ServerSocket ms; //<- Listener socket
    }I'm stumped as to where it is going wrong. I know that packVectors() and unpackVectors() both work, as they are used in a local save function. I suspect the problem lies between the getWBContent(String hid) and the fileListener class, but I am not certain where. Any help would be appreciated.

    First, you are expecting read(buffer,offset,count) to throw an EOFException. It doesn't, it returns -1 at EOF.
    Second, you are using a Writer to write binary data (resulting from serialization). This will corrupt it. Use an OutputStream.
    Third, what I really don't get is why would you (i) write local data to a file and (ii) start a new thread to (iii) read it back and (iv) send it over not one but two sockets, when you could just return the data as the result of the remote method without the file, the thread, or the Sockets.
    And in any case this sort of thing is most definitely not what SwingtUtilites.invokeLater() is for. (What it is for is updating Swing components and ensuring it all happens in the Swing thread, being the only correct way to write Swing code as Swing is not thread-safe by design.) If your server has a Swing GUI, which doesn't seem likely, it will stall for the duration of all this I/O. If it doesn't, why start the Swing thread at all?
    Just define a serializable object that contains all the data you are passing to writeObject()/writeInt() and return it as the result of the remote method.
    You will save yourself a lot of latency and code in the process, and you could reduce all this to about six lines of code, something like:
    return new WBContent(
    PageHolder, //Pages to file...
    ImgPage, //Images for the Pages to file...
    WBStack, //Current object stack to file...
    objCount, //Current object count to file...
    pageCount, //Current page count to file...
    pageCount-1 //Current page number to file...
    ); where WBContent is a serializable class with the appropriate members and constructor, and is the return type of getWBContent().

  • IIOP Java mode - proxy classes generation

    Hello,
    I have been able to use Jave-mode for call-in from a Java client to a
    Forte Server. Among the generated Java files, I observe that for each
    service object, there is also an IIOP proxy class - Java file with the
    _pxy name appended to the front.
    for example: ServerClass is a Tool Class, and there is a service object
    based on it. The "Make Distribution" process has generated the
    corresponding pxyServerClass.java also. It may be that the proxy
    files are generated for all Forte classes. I am not sure.
    The whole scheme of things has worked perfectly well for a simple test
    project that I wrote.
    But, there is another Plan, our Project's main Plan, that has some
    Supplier Plans, which in turn have a few other Supplier Plans, etc, the
    generated Java files does not have a single proxy class! I am unable to
    figure out why. Are there places that I should look for?
    In all, there are 2 DB Resouce Service Objects, 5 TOOL SOs in our
    application configuration. I tried switching the Distributed property
    from Allowed to IsDefault, but that didn't alter anything.
    Any help will be greatly appreciated.
    On a related note:
    When using IDL mode...
    Operator overriding is not allowed when using IDL2Java compiler of
    VisiBroker. You have class B that extends A. A method is redefined may
    be, with say different parameters. The .idl file won't compile, aborts
    with an error "attempt to redefine operator/varialbe". I heard from a
    colleague of mine (in fact I saw it compiling on his machine) that
    OrbixWeb allows this. This seemed like a basic requirement, it was hard
    to imagine that IDL syntax would not support that. Now, I realise that
    it is a problem with Visigenic product. Have other developers come
    across this problem? Is there a workaround?
    Thanks,
    Kishore Puvvada
    International Business Corporation
    Get Your Private, Free Email at http://www.hotmail.com
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    Hi Mark!!
       I would suggest you to check the components created for the Interface.  The main components of an Enterprise beans are like this:
    <Interface>_PortTypeImplRemote
    <Interface>_PortTypeImplRemoteHome
    <Interface>_PortTypeImplLocal
    <Interface>_PortTypeImplLocalHome
    <Interface>_PortTypeBean
    You can decompile if you have the Class file. It may be possible that the file got corrupted while creation.
    Decompile the file if you have only the class file(Use DJ Compiler or JAD.exe). This will tell you whether the error is with the bytecode of the bean class.
    Cheers!!
    AnuraG

  • Need help, I am terrible with Java, can someone help.

    Please can someone help me with this program. I am in a JAVA programming class and I am having a heck of a time. I am still having a problem with the basic concepts of JAVA but the teacher continues to give us difficult assignments with out any help. Here is the assignment:
    Write a class named 'Player' that has two attributes, 'name' (which has to be a 'Sting') and 'rating' (which has to be a 'int'). Then write an application class named "PlayerRating" that first creates an array consisting of 5 player objects, then display the list three times; first unsorted, then sorted by Name and finally sorted by rating.
    Must use the Bubble Sort Program and do NOT use Array.sort.
    Example output:
    Unsorted
    Name: Rating:
    Mickey Mantle 5
    Ty Cobb 3
    Babe Ruth 4
    Pete Rose 3
    Sammy Sosa 1
    Sorted by Name
    Name: Rating:
    Babe Ruth 4
    Mickey Mantle 5
    Pete Rose 3
    Sammy Sosa 1
    Ty Cobb 3
    Sorted by Rating
    Name: Rating:
    Sammy Sosa 1
    Pete Rose 3
    Ty Cobb 3
    Babe Ruth 4
    Mickey Mantle 5
    Here is what I have and it is not much, cause I am so lost:
    1 import java.io.*;
    2 import javax.swing.*;
    3 import java.text.*;
    4 import java.lang.*;//String[][];
    5 import java.util.*; //ArrayList;
    6
    7
    8 public class Player
    9 {
    10 public static void main (String [][]args)
    11 {
    12
    13 int maxSize = 100; //array size
    14 // String[][] s = new String[100][100]; //Default values: null
    15 boolean [] b = new boolean[4]; //default values: false
    16 int[][] i = new int[10][10]; //default values: 0
    17
    18
    19 PlayerRating arr; //reference to array
    20 //arr = new PlayerRating(maxSize);
    21 Sting player[]={"Mickey Mantle 5","Ty Cobb 3"
    22 ,"Babe Ruth 4","Pete Rose 3","Sammy Sosa 1"};
    23
    24
    25 }
    26 }
    Here is all I have on the second program:
    public class PlayerRating
    public void PlayerRating (int Max)
    int[][] i = new int[10][10];
    Please help I am totally lost.

    You repeat code, you should do a generic bubble sort with comparators, or declare class as Comparable. You can see how String class is Comparable, furthermore it has a final static Comparator for CASE_INTENSENSITIVE_ORDER.
    class User implements Comparable<User>{
      public static final java.util.Comparator<Cliente> RATING_COMPARATION=new java.util.Comparator<Cliente>(){
        public int compare(User u1,User u2){
               int comp=u1.rating-u2.rating;
               return comp==0?u1.name.compareTo(u2.name):comp;
         private String name;
         private int rating;
         public User(String name, int rating){
              setName(name);
              setRating(rating);
         public String getName(){
              return name;
         public void setName(String name){
              this.name = name;
         public int getRating(){
              return rating;
         public void setRating(int rating){
              this.rating = rating;
            // Compare users first by name and last by rating;
            public int compareTo(User anotherUser){
               int comp=name.compareTo(anotherUser.name);
               return comp==0?rating-anotherUser.rating:comp;
             public void equals(Object o){
              if(this==o)
                return true;
              if(o instanceof User){}
                 User anotherUser=(User)o;
                 return name.equals(anotherUser.name)&&rating==anotherUser.rating;
              return false;
               public int hashCode(){
                  return name.hashCode()+rating<<16;
    public class Sorting{
         public <E extends Comparable<E>>static void bubleSort(E[] arr){
              for(int i = 0; i < arr.length - 1; i++){
                   for(int j = arr.length - 1; j > i; j--){
                        if(arr[j].compareTo(arr[j - 1])<0)
                                     swap(arr,j,j-1);
         public static<E> void bubleSort(E[] arr,Comparator<E> cmp){
              for(int i = 0; i < arr.length - 1; i++){
                   for(int j = arr.length - 1; j > i; j--){
                        if(cmp.compare(arr[j],arr[j-1]) < 0)
                                      swap(arr,j,j-1);
            private static void swap(Object[] arr,int x,int y){
               Object tmp=arr[x];
               arr[x]=arr[y];
               arr[y]=tmp;
         public static void main(String[] args){
              User[] arr = new User[5];
              arr[0] = new User("Mickey Mantle", 5);
              arr[1] = new User("Ty Cobb", 3);
              arr[2] = new User("Babe Ruth", 4);
              arr[3] = new User("Pete Rose", 3);
              arr[4] = new User("Sammy Sosa", 1);
              System.out.println("Sorting by Name : ");
              bubleSort(arr)
              System.out.println(Arrays.toString(arr));
              System.out.println("Sorting by Rating : ");
              bubleSort(arr,User.RATING_COMPARATION);
              System.out.println(Arrays.toString(arr));
    }

  • Need help : how to send 3 parameters over http using Java POST

    I am trying to sending some data to agency company over http using Java POST
    They need 3 parameters and some contents like below
    1. Cmd : cmd=_RequestInsertNewLead
    2 Live : False
    3 XMLData : 3C%3Fxml+version%3D%........
    I already have XML done ,but I don't know how to send these guy over http
    is that like
    this.out = new DataOutputStream(os);
    out.writeBytes("Cmd");
    out.writeBytes(" cmd=_RequestInsertNewLead");
    out.writeBytes(" Live ");
    out.writeBytes("False");
    anyone could give help :)

    First of all, are you getting any exception?
    You didn't put much logging information in your code.
    You can also try this.Instead of doing sos.println(".....") try to build the output string using string buffer.
    Like:
    StringBuffer sb = new StringBuffer();
    sb.append("Some output");
    sb.append("More output");
    sos.print(sb.toString());
    sos.flush();Let me know if this works.

Maybe you are looking for

  • Result of agent resolution does not agree with agents of task

    Hello Experts,    I am trying to configure a workflow for Employee Travel expense, the Business object am using is BUS2089 for event CREATED.   And am configuring workflow task WS20000040 (Approve trip). and in the work flow builder I am assigning Us

  • XLA tables and column names while creating accounting in AP.

    Dear All, Could anybody please tell me what are the columns of the XLE tables gets hitted when i am creating accounting for an AP invoice? Also Please let me know from which tables and which columns, i can get all eligible invoices for payment? any c

  • What is the  use of Task Agent in pi 7.1 ?

    Hi Experts What is the  use of Task Agent in pi 7.1 ? What is the  use of Task Type in pi 7.1 ? What is the  use of Alert Category in pi 7.1 ? What is the  use of Step Group  in pi 7.1 ? Thanks G.Praveen Kumar

  • HDV1080i question

    I no this is not the ideal set up but its all I have at the moment. I'm shooting in HDV 1080i I'm editing on a late 08 mac book pro with final cut studio 2. The footage is captured as HDV. Render setting for the sequence is set to proress. If I send

  • Hiding subform in adobe form through javascript.

    Hi guys, I wanted to hide a subform through javascript. i want to make it visible only when the page no = 3. what is the syantax of javascript to do this. thanks in advance