File parser.

Hi,
I am trying to make file parser which can parse a uploaded documents. Here is the code. For some reason this code gives me no out but except a blank web page and also no compile error.... Whats missing?
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
* @author Owner
public class VectorMap extends HttpServlet {
   boolean fileLoad;
   public String fieldName;
   public String fileName;
   public String contentType;
   public boolean isInMemory;
   public long sizeInBytes;
    * Processes requests for both HTTP <code>GET</code> and <code>POST</code> methods.
    * @param request servlet request
    * @param response servlet response
    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException, FileUploadException {
        response.setContentType("text/html;charset=UTF-8");
        fileLoad = ServletFileUpload.isMultipartContent(request);
        // Create a factory for disk-based XML file items
        FileItemFactory factory = new DiskFileItemFactory();
        // Create a new XML file upload handler
        ServletFileUpload upload = new ServletFileUpload(factory);
        List items = upload.parseRequest(request);
        // Processing the uploaded XML
        Iterator iter = items.iterator();
        while (iter.hasNext()) {
        FileItem item = (FileItem) iter.next();
        // Processing a XML file upload
        if (!item.isFormField()) {
        fieldName = item.getFieldName();
        fileName = item.getName();
        contentType = item.getContentType();
        isInMemory = item.isInMemory();
        sizeInBytes = item.getSize();
        InputStream uploadedStream = item.getInputStream();
        uploadedStream.close(); // Closing reading of the uploaded file
        else{
            // Error parsing the file.
            response.sendRedirect("http://www.x.com/error.html");
     }// End of while    
        PrintWriter out = response.getWriter();
        try {
            out.println("<html>");
            out.println("<head>");
            out.println("<title>Servlet VectorMap</title>"); 
            out.println("</head>");
            out.println("<body>");
            out.println(fileName+"<br>"+fileName+"<br>"+contentType);
            out.println("</body>");
            out.println("</html>");
        } finally {
            out.close();
    } // End of processRequest Method
    // <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
    * Handles the HTTP <code>GET</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (FileUploadException ex) {
            Logger.getLogger(VectorMap.class.getName()).log(Level.SEVERE, null, ex);
    * Handles the HTTP <code>POST</code> method.
    * @param request servlet request
    * @param response servlet response
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
        try {
            processRequest(request, response);
        } catch (FileUploadException ex) {
            Logger.getLogger(VectorMap.class.getName()).log(Level.SEVERE, null, ex);
} // End of class

Throw in some debugging lines, find out what points execution reaches, how many times loops are executed, etc.

Similar Messages

  • Flat File Parsing

    The flat files are present in a unix server .
    No other application can be loaded there
    i have a lunix machine from where i have to access unix server data
    which is the better way
    1)directly reading the file from the unix server
    2)loading the file in lunix and then reading
    How this can be done in java ????
    Now lets say we are reading the file in some way or the other ,How to do i parse it
    File parsing
    different file:
    1)fixed format
    file size 50 mb
    eg
    a)the data will be in fixed column size
    0-60 -name
    61-70 -department
    71-80 -age
    b)there will be section strip data for a particular section
    Note :-Here i have to parse a particular section from the flat file the size of file is 50mb?
    eg
    section-Finance
    name               department          age     
    Smith               dep1               32
    john               dep2               40
    turner               dep3               56     
    section-marketing
    name               department          age
    antony               dep1               60     
    black               dep2               57
    2)csv file
    file size 15 kb
    here the data size will be not be fixed but will have a seperator
    name|department|age     
    Smith|dep1|32
    john|dep2|40
    turner|dep3|56     
    antony|dep1|60     
    black|dep2|57
    here seperator is | it can be anything
    Thanx in advance
    Meghna

    Xml Convert:
    http://industry.java.sun.com/solutions/products/by_product/0,2348,all-4398-99,00.html
    Flat File to Xml Converion:
    http://www.infoloom.com/gcaconfs/WEB/philadelphia99/lyons.HTM

  • 'Import file parsing exception' while importing BIAR file

    Hi All,
    We use Java WebServices SDK for integrating our product with Business Objects. For installing the reports we use the InstallEntSDKWrapper jar to copy the BIAR file containing the reports on to the BO server. Till now we were using BO XI R2 and everything works fine.
    But now we have decided to upgrade to BO 3.0 and the reports install no longer works. Here is the error that we get -
    [InstallEntSdkWrapper.main] Connecting to CMS rwc-1950-120:6400 as administrator
    [InstallEntSdkWrapper.CmsImportFile] Exception: Import file parsing exception
    curred : 'Type info incomplete'
    [InstallEntSdkWrapper.main] BIAR File could not be imported
    Any idea what might be going wrong here? We are trying to import the same BIAR file that were created with the earlier BO version to the 3.0 version server. Couple of questions that I have is -
    1. Do we need to repackage the BIAR with 3.0 before attempting to install it? Are there any issues with trying to install a BIAR which is of older BO version?
    2. Do we need to add/modify any library (jar) in the runtime to get rid of the exception?
    Thanks for all the help.
    Regards
    Manas
    Edited by: Manas Mandlekar on Dec 23, 2009 1:34 AM

    Lucas,
    I have not seen this issue before. We'll investigate and contact you directly for more info. I'll post the resolution back to this forum once available.
    Doug

  • File Parsing question

    Say I have a fairly big file. Many megs, for example. My file can be formatted kind of the way I want, but it contains data in a key-value pair format, where the key is a long (ordered) and the value is a string of variable length.
    So, for example, it could look something like this:
    1blabla
    2bobob
    3gugugu
    99910102923tututu
    Now, I know I can get the value for a specific key by parsing the lines, reading a long when reading a string. This is fine.
    But I'm trying to be somewhat smarter. Since I know my longs are ordered, I'm thinking I can implement a search algorithm that looks in the middle of an interval for the looked value, to eliminate half the remaining options per pass.
    I can use randomaccessfile to get to some random point in the file. That's fine. But now, since I can be at any point of the file, I could be within the long, or somewhere within the string. What I'm looking for, and can't seem to figure out, is how to get back to the beginning of the long value, to read it correctly.
    Any pointers appreciated!

    First reason is I'm trying to build something for unstructured data. Databases are usually good only for structured data. I could put everything in text, I suppose.
    Second reason is databases are, in theory, slower than intelligent file-parsing. You have to generate the connection, have the dbms manipulate the data then return the data then have the driver translate it to something your programming language understands. I know, I Know, I'd have to work years to make something as efficient as an existing DB.
    Third reason is databases usually require a database engine, so if I wanted to make a standalone application, with, say, a jar file, I could avoid requiring of my userd to install some database application. Yes, there are some embedded database thignies out there.
    Fourth reason is curiosity. I want to see if I can do something like this because I've never done it before, and I'm interested in finding out if it's possible or not!

  • File Parser that allows me to add/remove rows in a file

    Hi,
    Have been trying to write a file parser that takes as input a file containing > 100,000 lines. I am parsing each line with a given delimiter and pulling out the fields I require but the response is very slow. I'm loading the data into a JTable for viewing (So I now have a spread sheet )but what I want now is the ability to add/remove entire rows. I can't do this with a JTable, can only edit columns within rows. Does any one know of a better approach?
    Thanks ... J

    What I need to do is present all the rows to the user and have them delete/edit rows at will but only through the GUI. JTable has a delete row method but the problem I'm having is getting the modified data from the JTable to a file.
    ie, file looks like
    Name|Address|Number
    Joe|some St|111
    Mick|My Rd|222
    Mary|My Ave|333
    I want to present this data in a JTable ... done.
    Now want to remove Mick row and change Mary's number to 999
    So new file should now contain
    Name|Address|Number
    Joe|some St|111
    Mary|My Ave|999
    But problem is I'm dealing with > 200 columns and > 100,000 rows

  • Help ! weblogic server 5.0.1 license file parse error

    I just get a weblogic server 5.0.1 evaluation version CD .After I install it on my machine(MY OS is win2000 ),I get the license key from the bea web site and copy it to "d:\weblogic\licenses" derectory ,but when I use
    "java utils.showLicenses -Dweblogic.system.home=d:\weblogic
    -classpath=d:\weblogic\classes ;d:\weblogic\licenses
    -Dweblogic.class.path=d:\weblogic\classes"
    to look the license ,it throw a exception ,like this:
    weblogic.common.LicenseException:weblogic.common.CorruptException: Error parsing XML license file
    this is my license key file :
    <!-- Keys for version 4.0 and later -->
    <WEBLOGIC-LICENSES>
    <LICENSE PRODUCT="WebLogic"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="60f3b77d6036b44cc968f1b0db87593b"
    />
    <LICENSE PRODUCT="WebLogic/SSL"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="a86b320c95ecd8d73108ac537288fa53"
    />
    <LICENSE PRODUCT="jdbcKona/MSSQLServer4"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="e658f24242058b9c72937929459e4e75"
    />
    <LICENSE PRODUCT="jdbcKona/Informix4"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="f90045487fd2c26bd5720e53599ab28a"
    />
    <LICENSE PRODUCT="jdbcKona/Oracle"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="d95225c8561ed63484bc561e0d864698"
    />
    <LICENSE PRODUCT="jdbcKona/Sybase"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="a47e9718bad8e2bf97ba6e58bb0810d4"
    />
    <LICENSE PRODUCT="jdbcKona/MSSQLServer"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="2f1664480679796de7a005a8fcc3089b"
    />
    </WEBLOGIC-LICENSES>
    can anyone tell me the cause ? thanks a lot !

    The license must be in your classpath.
    Thanks,
    Michael
    Michael Girdley
    BEA Systems Inc
    "fengyanb" <[email protected]> wrote in message
    news:39e3da22$[email protected]..
    >
    I just get a weblogic server 5.0.1 evaluation version CD .After I installit on my machine(MY OS is win2000 ),I get the license key from the bea web
    site and copy it to "d:\weblogic\licenses" derectory ,but when I use
    "java utils.showLicenses -Dweblogic.system.home=d:\weblogic
    -classpath=d:\weblogic\classes ;d:\weblogic\licenses
    -Dweblogic.class.path=d:\weblogic\classes"
    to look the license ,it throw a exception ,like this:
    weblogic.common.LicenseException:weblogic.common.CorruptException:Error parsing XML license file
    >
    this is my license key file :
    <!-- Keys for version 4.0 and later -->
    <WEBLOGIC-LICENSES>
    <LICENSE PRODUCT="WebLogic"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="60f3b77d6036b44cc968f1b0db87593b"
    />
    <LICENSE PRODUCT="WebLogic/SSL"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="a86b320c95ecd8d73108ac537288fa53"
    />
    <LICENSE PRODUCT="jdbcKona/MSSQLServer4"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="e658f24242058b9c72937929459e4e75"
    />
    <LICENSE PRODUCT="jdbcKona/Informix4"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="f90045487fd2c26bd5720e53599ab28a"
    />
    <LICENSE PRODUCT="jdbcKona/Oracle"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="d95225c8561ed63484bc561e0d864698"
    />
    <LICENSE PRODUCT="jdbcKona/Sybase"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="a47e9718bad8e2bf97ba6e58bb0810d4"
    />
    <LICENSE PRODUCT="jdbcKona/MSSQLServer"
    IP="any" UNITS="3" EXPIRATION="07-Nov-2000"
    KEY="2f1664480679796de7a005a8fcc3089b"
    />
    </WEBLOGIC-LICENSES>
    can anyone tell me the cause ? thanks a lot !

  • XML file parse issue

    I have a requirement to print <attribute-override> and <column> in a spreadsheet.
    My xml file is as
    <?xml version="1.0" encoding="UTF-8"?>
    <entity-mappings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/orm" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eclipse.org/eclipselink/xsds/persistence/orm http://www.eclipse.org/eclipselink/xsds/eclipselink_orm_2_4.xsd">
      <entity class="com.ofss.fc.domain.account.entity.accountcreditmatrix.CreditMetricDetails">
        <table name="FLX_AC_ACCT_CREDIT_MATRIX_DTLS"/>
        <attributes>
          <embedded-id attribute-type="com.ofss.fc.domain.account.entity.accountcreditmatrix.CreditMetricDetailsKey" name="key">
            <attribute-override name="accountId">
              <column name="ACCOUNT_ID"/>
            </attribute-override>
            <attribute-override name="accountType">
              <column name="ACCOUNT_TYPE"/>
            </attribute-override>
            <attribute-override name="effectiveDate">
              <column name="EFFECTIVE_DATE"/>
            </attribute-override>
            <attribute-override name="matrixIdvalue">
              <column name="MATRIX_ID_VALUE"/>
            </attribute-override>
            <attribute-override name="classification">
              <column name="Classification"/>
            </attribute-override>
          </embedded-id>
          <embedded attribute-type="com.ofss.fc.domain.account.entity.accountcreditmatrix.CreditMetric" name="creditMetric">
            <attribute-override name="metricType">
              <column name="METRIC_TYPE" unique="false"/>
            </attribute-override>
            <attribute-override name="metricValue">
              <column name="METRIC_VALUE" unique="false"/>
            </attribute-override>
          </embedded>
          <embedded attribute-type="com.ofss.fc.domain.account.entity.accountcreditmatrix.RiskScore" name="riskScore">
            <attribute-override name="scoreType">
              <column name="SCORE_TYPE" unique="false"/>
            </attribute-override>
            <attribute-override name="otherScoreType">
              <column name="OTHER_SCORE_TYPE" unique="false"/>
            </attribute-override>
            <attribute-override name="scoreCardExternalReferenceNo">
              <column name="SCORE_EXTR_REF_NO" unique="false"/>
            </attribute-override>
            <attribute-override name="ratingModel">
              <column name="RATING_MODEL" unique="false"/>
            </attribute-override>
            <attribute-override name="ratingStatus">
              <column name="RATING_STATUS" unique="false"/>
            </attribute-override>
            <attribute-override name="riskGrade">
              <column name="RISK_GRADE" unique="false"/>
            </attribute-override>
            <attribute-override name="scoreCardIndex">
              <column name="SCORE_CARD_INDEX" unique="false"/>
            </attribute-override>
            <attribute-override name="score">
              <column name="SCORE" unique="false"/>
            </attribute-override>
          </embedded>
        </attributes>
      </entity>
    </entity-mappings>
    I have managed to write the code as
    package xmlexcel;
    import org.apache.poi.hssf.usermodel.*;
    import java.util.ArrayList;
    import java.awt.List;
    import java.io.*;
    import java.util.ArrayList;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.xml.sax.SAXException;
    import org.apache.poi.hssf.usermodel.HSSFCell;
    import org.apache.poi.hssf.usermodel.HSSFRow;
    import org.apache.poi.hssf.usermodel.HSSFSheet;
    import org.apache.poi.hssf.usermodel.HSSFWorkbook;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    public class XMLconvertExcel {
      private static File xmlDocument;
        private static NodeList e;
        int a;
      public void generateExcel(File xmlDocument) {
      try {
      HSSFWorkbook wb = new HSSFWorkbook();
      HSSFSheet spreadSheet = wb.createSheet("spreadSheet");
      spreadSheet.setColumnWidth((short)0,(short) (256*25));
      spreadSheet.setColumnWidth((short)1,(short) (256*25));
      spreadSheet.setColumnWidth((short)2,(short) (256*25));
      spreadSheet.setColumnWidth((short)3,(short) (256*25));
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      DocumentBuilder builder = factory.newDocumentBuilder();
      Document document = builder.parse(xmlDocument);
      NodeList nList = document.getElementsByTagName("attributes");
      document.getDocumentElement().normalize();
      //a=nodelist.getLength();
      //e = printStackTrace();
      //System.out.println("I am here " +e);
             System.out.println("Root element :" + document.getDocumentElement().getNodeName() + " nlist length  " +nList.getLength());
             System.out.println("Node Type :" + document.getDocumentElement().getNodeType());
      HSSFRow row = spreadSheet.createRow(0);
      HSSFCell cell = row.createCell((short)0);
      cell.setCellValue("Entity");
      cell = row.createCell((short)1);
      cell.setCellValue("Table");
      cell = row.createCell((short)2);
      cell.setCellValue("Attribute");
      cell = row.createCell((short)3);
      cell.setCellValue("Column");
      HSSFRow row1 = spreadSheet.createRow(1);
      HSSFRow row2 = spreadSheet.createRow(2);
      HSSFRow row3 = spreadSheet.createRow(3);
      for (int i = 0; i < nList.getLength(); i++) {
      Node nNode = nList.item(i);
                 System.out.println("\nCurrent Element :"    + nNode.getNodeName());
                 switch {
      case 0:
      //cell = row1.createCell((short)0);
      //cell.setCellValue("Attribute");
      //trying from http://architects.dzone.com/articles/parsing-xml-using-dom-sax-and
      cell = row1.createCell((short) 2);
                    cell.setCellValue(((Element) (nList.item(0)))
                       .getElementsByTagName("attribute-override").item(0)
                       .getFirstChild().getNodeValue());
      break;
      case 1:
      //cell = row1.createCell((short)1);
      //cell.setCellValue("Table");
      cell = row1.createCell((short) 3);
      cell.setCellValue(((Element) (nList.item(0)))
      .getElementsByTagName("column").item(0)
      .getFirstChild().getNodeValue());
      break;
      case 2:
      cell = row1.createCell((short)2);
      cell.setCellValue("Attribute");
      cell = row1.createCell((short) 2);
      cell.setCellValue(((Element) (nodelist.item(2)))
      .getElementsByTagName("attribute-override").item(0)
      .getFirstChild().getNodeValue());
      cell = row1.createCell((short)3);
      cell.setCellValue("Column");
      cell = row1.createCell((short) 3);
      cell.setCellValue(((Element) (nodelist.item(3)))
      .getElementsByTagName("column").item(0)
      .getFirstChild().getNodeValue());
      break;
      default:
      break;
      //wb.write(arg1.getOutputPayload().getOutputStream());
      //Outputting to Excel spreadsheet
      FileOutputStream output = new FileOutputStream(new File("C:\\java_training\\com\\XMLtoExcel\\ormaccount.xls"));
             wb.write(output);
             output.flush();
             output.close();
      } catch (IOException e) {
      System.out.println("IOException " + e.getMessage());
      } catch (ParserConfigurationException e) {
      System.out.println("ParserConfigurationException " +e.getMessage());
      }catch (SAXException e) {
      System.out.println("SAXException " +e.getMessage());
      private String printStackTrace() {
      // TODO Auto-generated method stub
      return null;
      * @param args
      public static void main(String[] args) {
      File xmlDocument = new File("C:\\java_training\\com\\XMLtoExcel\\AccountCreditMatrixDetails.orm.xml");
      XMLconvertExcel excel = new XMLconvertExcel();
      excel.generateExcel(xmlDocument);
    Both the tags are not getting printed in separate columns.
    I have looked at
    http://www.javaworld.com/article/2076189/enterprise-java/book-excerpt--converting-xml-to-spreadsheet--and-vice-versa.html
    http://scn.sap.com/thread/3224533
    http://www.tutorialspoint.com/java_xml/java_dom_parse_document.htm
    The above URL shows example of simple xml.
    Please can I get assistance.

    I too received this error as I tried to run my first Windows 8.1 deployment. Per another post I commented out this line
    <IEWelcomeMsg>false</IEWelcomeMsg>
    from the IE section of the unattend.xml. I was then able to run my deployment. I do not see this line in your posting though.
    I referenced this link even though it was for Windows 7.
    http://social.technet.microsoft.com/Forums/en-US/c41a2b69-a591-4cd3-86ab-6a0f8a73b858/getting-windows-could-not-parse-or-process-the-unattend-answer-file-for-pass-specialize-with?forum=mdt
    Hope this helps someone.
    JayTheTech
    To clarify, I edited the unattend.xml file from from Deployment Share, not C:\Windows\Panther.
    DS\control\task sequence ID\unattend.xml
    JayTheTech

  • Xml file parse  event base

    hello all,
    i am learning xml file with sap help sample. I have a FM, that change xml-file into if_ixml_parser, but when i wrote the xml " <person status="retired">Walt Whitman</person>" and debug it.
    event_sub was 312, <b>event was always initial</b>.
    data: event     type ref to if_ixml_event,
            event_sub type i.
    let the parser know which events I am interested in
    event_sub = if_ixml_event=>co_event_element_pre2 +
                if_ixml_event=>co_event_element_post.
    parser->set_event_subscription( events = event_sub ).
    do.
      event = parser->parse_event( ).
      if event is initial.
        exit. ' either end reached or error (check below)
      endif.
      data: str type string.
      case event->get_type( ).
        when if_ixml_event~co_event_element_pre2.
          str = event->get_name( ).
          write: '<' str '>'.
        when if_ixml_event~co_event_text_post.
          str = event->get_value( ).
          write: str.
      endcase.
    enddo.
    Thanks for Request.
    <a href="http://help.sap.com/saphelp_nwmobile71/helpdata/de/47/b5413acdb62f70e10000000a114084/frameset.htm">sap library - Parsing an XML document event-based</a>
    Best regards
    Shuo

    Hi,
         reference link:
    http://help.sap.com/saphelp_nw04/helpdata/en/fd/9d7348389211d596a200a0c94260a5/frameset.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/bb/576670dca511d4990b00508b6b8b11/content.htm
    Please see the PDF document which tells you how to develop with KM API's
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/aef1a890-0201-0010-6faf-8fa094808653
    Regards

  • Data File Parsing in CVI

    Hi guys,
    I'm new in LabWindows. I have a simple project, which has to parse a .txt file. Only some data inside the txt-File is interesting (the middle part, segment # 1-3 -> see example). The upper and lower part differs in size and is not important. Are there predefined LabWindows function, which I may use, or do I have to code it in C?
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Program Run:    xxxxxxxxxxxxxxxxxxxxxx                       Model: xxxxxxxxxxx
    Description:    xxxxxxxxxxxxxxxxxxxxxx                                              
    xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
                                         xxxxxxxxx
    Seg-  Segm.  Run   |  Mix   |  RMV  GasVol   Max   Max     CNS    CPTD    END     END
     ment  Time   Time  |  Used|    liter   Segm.    A     B      %        %     N2      N2+O2
      #   (min)  (min) |    #   | /min  liters  (mswg) Segm.   Segm.  Segm.  (mswg)  (mswg)
    ----- -----  ----- | ------ | ----  ------  ------ -----  ------  -----  ------  ------
      1     0.1    0.1 |    1   |20.00     4.0    20.  0.62     0.0%    0.0     20.     20.
      2    19.9   20.0 |   1   |20.00  1178.4    20.  0.62     2.9%    6.1     20.     20.
      3     2.2   22.2 |   1   |20.00    87.7    20.  0.62     0.1%    0.1     20.     20.
                                                                3.0%    6.2
                                                               Total  Total
                                                      with 1.5
    xxxxxxxxxxxxxxxxxxxxx:                 liters     safety factor
                             Mix    # 1    1270.1     1905.1

    ... delete your second call of ReadLine and it should work
    HansiWWW wrote:
    It works very nice...
    The only problem I currently have is, that it only prints out every second line????????
    int CVICALLBACK AddCallback (int panel, int control, int event,
                                 void *callbackData, int eventData1,
                                 int eventData2)
        int error = 0;
        int status = 0;
        int filehandle = 0;
        char str[351]; 
        if (event == EVENT_COMMIT) {
            filehandle = OpenFile("test.dat", VAL_READ_ONLY, VAL_OPEN_AS_IS, VAL_ASCII);
             while(1) {
                  status = ReadLine(filehandle, str, 350);
                // end of file reached
                  if(status == -2)
                    break;    
                // Error found
                  else if(status == -1) {   
                    //error = GetFmtIOErrr ( );
                    break;
                else {
                    ReadLine(filehandle, str, 350);
                        strcat(str, "\n");
                        SetCtrlVal (panel, PANEL_ACTIONBOX, str);           
            CloseFile (filehandle);
        return 0;

  • Text file parsing and output

    Hi,
    I'm extremely new to Java and need to read and parse a text file and generate a new text file with modifications as follows:
    1. Ignore and rewrite comments
    2. Ignore and rewrite compiler commands
    3. (a) Modify function prototypes be removing their return values, if any,
    (b) append an '_VAR' to the function name and args
    (c) add an ampersand to the args when passed by reference
    sample input file:
    /***** comment *****/
    #if (INCLUDE_STATIC_BUILD == OS_FALSE)
    extern OS_MEMORY_POOL *MEM_Non_Cached;
    #endif
    UINT16 TLS_IP_Check (const UINT16 *s, UINT16 len);
    INT32 MEM_Copy_Data(NET_BUFFER buf_ptr, const CHAR HUGE buffer, INT32 numbytes, UINT16 flags);
    sample output file:
    /***** comment *****/
    #if (INCLUDE_STATIC_BUILD == OS_FALSE)
    extern OS_MEMORY_POOL *MEM_Non_Cached;
    #endif
    UINT16_VAR = TLS_IP_Check (&UINT16_VAR, UINT16_VAR);
    INT32_VAR = MEM_Copy_Data(&NET_BUFFER_VAR, name, INT32_VAR, UINT16_VAR);
    I would appreciate any help!
    Thanks.

    Check replies on the other post
    http://forum.java.sun.com/thread.jspa?threadID=680728&tstart=0

  • Ignoring white lines in a file parsed with Scanner

    I've a little problem...
    How to ignore white lines in a file (for configuration informations) parsed with Scanner???
    My parser can ignore #(comments) and other thing, but not white lines...
    oooo
    fucking little problem!!!
    Thank for solutions...
    euronymous

    Wrong assumption. Scanner doesn't return lines, it returns tokens separated by delimiters which are whitespace by default, so by default it will already ignore blank lines.
    If you are using custom delimiters, make sure to include space, tab, and newline (\r \n and \f) as delimiters.

  • JSP XML file parsing XSLT using Xalan

    Hi all
    I have created an XML file "view_campaign.xml" using JSP as shown in a code below and i wanna know how i should proceed to parse the XML file and so i can display this XML as the XSLT file i created.
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%
    // Identify a carriage return character for each output line
    int iLf = 10;
    char cLf = (char)iLf;
    // Create a new empty binary file, which will content XML output
    File outputFile = new File("C:\\WebContent\\view_campaigns.xml");
    //outputFile.createNewFile();
    FileWriter outfile = new FileWriter(outputFile);
    // the header for XML file
    outfile.write("<?xml version='1.0' encoding='ISO-8859-1'?>"+cLf);
    try {
         // Define connection string and make a connection to database
         //DriverManager.registerDriver (new org.apache.derby.jdbc.ClientDriver());
         Connection conn = DriverManager.getConnection("jdbc:derby://localhost:1527/sample","app","app");
         Statement stat = conn.createStatement();
         // Create a recordset
         ResultSet rset = stat.executeQuery("Select * From campagn");
         // Expecting at least one record
         if( !rset.next() ) {
              throw new IllegalArgumentException("No data found for the campaigns table");
         outfile.write("<campaigns>"+cLf);
         outfile.write("<campaign>"+cLf);
         outfile.write("<campaign_id>" + rset.getString("campagn_id") +"</campaign_id>"+cLf);
         outfile.write("<campaign_name>" + rset.getString("campagn_name") +"</campaign_name>"+cLf);
         outfile.write("<campaign_type>" + rset.getString("campagn_type") +"</campaign_type>"+cLf);
         outfile.write("<client>" + rset.getString("client_name") +"</client>"+cLf);
         outfile.write("<positions>" + rset.getString("positions_nbr") +"</positions>"+cLf);
         outfile.write("<begin>" + rset.getString("campagn_beginning_date") +"</begin>"+cLf);
         outfile.write("<close>" + rset.getString("campagn_ending_date") +"</close>"+cLf);
         outfile.write("</campaign>"+cLf);
         // Parse our recordset
    // Parse our recordset
         while(rset.next()) {
              outfile.write("<campaign>"+cLf);
              outfile.write("<campaign_id>" + rset.getString("campagn_id") +"</campaign_id>"+cLf);
              outfile.write("<campaign_name>" + rset.getString("campagn_name") +"</campaign_name>"+cLf);
              outfile.write("<campaign_type>" + rset.getString("campagn_type") +"</campaign_type>"+cLf);
              outfile.write("<client>" + rset.getString("client_name") +"</client>"+cLf);
              outfile.write("<positions>" + rset.getString("positions_nbr") +"</positions>"+cLf);
              outfile.write("<begin>" + rset.getString("campagn_beginning_date") +"</begin>"+cLf);
              outfile.write("<close>" + rset.getString("campagn_ending_date") +"</close>"+cLf);
              outfile.write("</campaign>"+cLf);
         outfile.write("</campaigns>"+cLf);
         // Everything must be closed
         rset.close();
         stat.close();
         conn.close();
         outfile.close();
    catch( Exception er ) {
    %>////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    this is my .XSL file
    <?xml version="1.0" encoding="iso-8859-1" ?>
    - <!--  DWXMLSource="view_campaigns.xml"
      -->
      <!DOCTYPE xsl:stylesheet (View Source for full doctype...)>
    - <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output method="html" encoding="iso-8859-1" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" />
    - <xsl:template match="/">
    - <html xmlns="http://www.w3.org/1999/xhtml">
    - <head>
      <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
      <title>Gestion des campagnes</title>
      </head>
    - <body>
      Gestion des campagnes
    - <table border="1">
    - <tr bgcolor="#9acd32">
      <th align="left">Code</th>
      <th align="left">Nom</th>
      <th align="left">Type</th>
      <th align="left">Client</th>
      <th align="left">Nombre de positions</th>
      <th align="left">Date d'ouverture</th>
      <th align="left">Date de cl�ture</th>
      </tr>
    - <xsl:for-each select="campaigns/campaign">
    - <tr>
    - <td>
      <xsl:value-of select="campaign_id" />
      </td>
    - <td>
      <xsl:value-of select="campaign_name" />
      </td>
    - <td>
      <xsl:value-of select="campaign_type" />
      </td>
    - <td>
      <xsl:value-of select="client" />
      </td>
    - <td>
      <xsl:value-of select="positions" />
      </td>
    - <td>
      <xsl:value-of select="begin" />
      </td>
    - <td>
      <xsl:value-of select="close" />
      </td>
      </tr>
      </xsl:for-each>
      </table>
      </body>
      </html>
      </xsl:template>
      </xsl:stylesheet>I would be greatful that u answer my question what i should do have any exemple case study.

    Hi,
    Try this code
    JspWriter out = pageContext.getOut(); // Get JSP output writter
          javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance(); //Instantiate a TransformerFactory.           
          String realPath = "c:/applyXsl.xsl";
          java.io.File file = new java.io.File(realPath); // crearte a file object for given XSL.
          // Use the TransformerFactory to process the stylesheet Source and  generate a Transformer.           
          javax.xml.transform.Transformer transformer = tFactory.newTransformer(new javax.xml.transform.stream.StreamSource(file));
          java.io.StringReader inputStream = new java.io.StringReader("c:/xmlFile.xml"); // create an input stream for given XML doc
          java.io.ByteArrayOutputStream obj = new java.io.ByteArrayOutputStream(); // Create an output stream for XSL applied XML doc.
          // 3. Use the Transformer to transform an XML Source and send the output to a Result object.
          transformer.transform(new javax.xml.transform.stream.StreamSource(inputStream), new javax.xml.transform.stream.StreamResult(obj));
          String outputString = obj.toString(); // get the XSL applied applied XML document for print
          out.println(outputString); // print the XSL applied XML in to JSP.
    however you need xercesImpl.jar  and xml-apis.jar files  to run this program.
    Regards,
    Ananth.P

  • XML file parser

    Is there some Java package which able me to parse a XML file ?
    a method like as:
    public Enumeration parseXML(File file);
    ?????????

    Yes,
    You've the package named: javax.xml.parsers
    And you've a class called: javax.xml.parsers.SAXParser
    To know more about parsers, java.sun.com/xml
    There are many different parsers available based on SAX (Simple API for XML Parsing) and DOM!
    -RK.

  • Need to rename files parsing date formats in the filename [SOLVED]

    Godaddy changed the naming scheme of their server logs again.  I need some perl or something magic that will convert format A to format B.  Doing this is bash is going to be painful so I'm hoping some of your perl or python ninjas out there could help me.
    format A:  ex20140425000001.log
    format B: Wed, May 21, 2014.log
    So for the example above, that date needs to be converted to this name: ex20140521000001.log
    Thanks in advance!
    EDIT: nevermind... forgot about date.
    #!/bin/bash
    for i in *.log; do
    fixeddate="$(echo $i | sed -e 's/,//g' -e 's/^....//' -e 's/.log//')"
    useitdate="$(date -d "$fixeddate" +%Y%m%d%H%M%S)"
    newname="ex$useitdate.log"
    mv "$i" "$newname"
    done
    Last edited by graysky (2014-06-07 09:41:59)

    sempervirent,
    You're asking for some pretty advanced file naming. Most people aren't going to need that sort of function, so I doubt there will be a hook into Aperture to do such a thing. I suggest using a shell script or Applescript along with EXIFTool to rename files before you import them into Aperture. http://www.sno.phy.queensu.ca/~phil/exiftool/
    Retain the unique number that the image already has
    If you're not afraid of the command line, it's easy enough to use a tool like awk or maybe perl to parse that sequence number from a well-formatted string like the picture name
    Replace "DSC" with the camera model (D3X)
    You can use EXIFTool to extract the camera model from the EXIF dat ain the photos
    Add a digit prior to the four-digit string to indicate the true numeric sequence of the file.
    Good luck with this one. You'll have to do a filename search through all of your previous files to find out what 10,000 you're on. It's possible, but you'd have to do some specialized coding in AppleScript or shell script.
    nathan

  • Specific text file parsing

    Hello.
    Anyone have an idea how to parse txt file in format
    [2014-12-27 20:44:02] Server->request : Array
        [login] => 1111111
        [date] => 2014-12-29
        [dealid] => 111111111
        [details] => Array
                [Exception] => Array
                        [field] => Array
                                  [errors] =>
    Array
                                       [error]
    => Array
    [code] => 15896
    [description] =>not possible

    Its multiple sequences
    [2014-12-27 20:44:02] Server->request : Array
    [2014-12-27 20:50:01] Server->request : Array
    I need to get date
    [2014-12-27 20:44:02], login [login] => 1111111, and err code  [code] => 15896

Maybe you are looking for

  • Why won'tiMac won't go into target disk mode?

    starting in 'T' doen't help, it plows on to loading up.

  • Why is my SQL not using an index?

    I have a small SQL query (10g) where I join to basic table together on a customer_id column. select * from customer c inner join work_item sp1 ON sp1.customer_id = c.customer_id and I am using TOAD, which tells me (in the Explain Plan area), that I'm

  • Transactional Triggers

    Hi, I'm new in oracle forms. I've been reading different documents/online help etc. But i'm confuse with the Transactional Triggers like On-Insert, On-Update, On-Delete. I mean when we should use On-Insert/On-Update/On-Delete? We can use regular inse

  • IPhoto '08 to iPhoto '11 - lost photo's??? Help

    I upgraded to MtnLion from Lion and then iPhoto '08 to iPhoto '11. Now all my photo's from mid-2009 to present are not in my iMac Library, but are on my iPad??? How can I correct this?

  • Connect/Socket Timedout Exception is not thrown

    Hi, I am getting the following problem very often. when I tried to connect to some URLs I am not able to connect those URLs and they didnot thrown any exceptions also but the process will be running until we kill explictly. here is my code URL url =