Java logging - xml

I've just started using the java logger (java.util.logging.*;).
It outputs to a file in XML format. Is there a way to have it output plain text?
ie just what is in the statements i write, like this:
logger.info( "MyClass.someMethod(): hello\n" );

In the JRE\lib, there is a file called logging.properties where the defaults are set.
You can modify the line :
java.util.logging.FileHandler.formatter = java.util.logging.XMLFormatterto
java.util.logging.FileHandler.formatter = java.util.logging.SimpleFormatter
/code]
or do it from your code import java.util.logging.*;
FileHandler fh = new FileHandler("TestLog.log", append);
//fh.setFormatter(new XMLFormatter());
fh.setFormatter(new SimpleFormatter());
logger = Logger.getLogger("TestLog");
logger.addHandler(fh);
or provide your own logging.properties when starting the JVM with the option
-Djava.util.logging.config.file=mylogging.propsMore tips at http://www.rgagnon.com/javadetails/java-0501.html
Bye.

Similar Messages

  • Entries with oracle's IP in log.xml file.

    This is about a couple of log entries I found in /dcm/logs/emd_logs/log.xml file.
    while I have some Idea about the message itself what I don't understand is why the <HOST_NWADDR> points to 148.87.12.57
    Can anyone shed some light on this.
    Does R2 connect to oracle in some way each time it is brought up, 'cause the IP 148.87.12.58 is the IP of the PortalStudio and I figured its neighbour belongs to oracle too.
    Do I need to keep the box connected to Internet all the time for it to work.
    Could someone at oracle tell me what my box is trying to do by connecting to 148.87.12.57.
    Please find the entries below.
    Thanx
    Vinodh R.
    These are the entries I found
    i)
    <MESSAGE>
    <HEADER>
    <TSTZ_ORIGINATING>2002-07-08T03:56:36.721-04:00</TSTZ_ORIGINATING>
    <COMPONENT_ID>OC4J</COMPONENT_ID>
    <MSG_TYPE TYPE="ERROR"></MSG_TYPE>
    <MSG_GROUP>n/a</MSG_GROUP>
    <MSG_LEVEL>1</MSG_LEVEL>
    <HOST_ID>myportal</HOST_ID>
    <HOST_NWADDR>148.87.12.57</HOST_NWADDR>
    <MODULE_ID>iAS_dcm/oracle/defaultLogger/ExceptionLogger</MODULE_ID>
    <PROCESS_ID>null-Thread[ApplicationServerThread,5,applicationServerThreadGroup]</PROCESS_ID>
    <USER_ID>root</USER_ID>
    </HEADER>
    <PAYLOAD>
    <MSG_TEXT>[ RM ] Exception in repository API new SchemaManager()</MSG_TEXT>
    <SUPPL_DETAIL><![CDATA[oracle.ias.repository.schema.SchemaException: Password could not be retrieved
         at oracle.ias.repository.IASSchema.init(IASSchema.java:152)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243)
         at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
    ]]></SUPPL_DETAIL>
    </PAYLOAD>
    </MESSAGE>
    ii)
    <MESSAGE>
    <HEADER>
    <TSTZ_ORIGINATING>2002-07-08T06:41:27.339-04:00</TSTZ_ORIGINATING>
    <COMPONENT_ID>OC4J</COMPONENT_ID>
    <MSG_TYPE TYPE="ERROR"></MSG_TYPE>
    <MSG_GROUP>n/a</MSG_GROUP>
    <MSG_LEVEL>1</MSG_LEVEL>
    <HOST_ID>myportal</HOST_ID>
    <HOST_NWADDR>148.87.12.57</HOST_NWADDR>
    <MODULE_ID>iAS_dcm/oracle/defaultLogger/ExceptionLogger</MODULE_ID>
    <PROCESS_ID>null-Thread[ApplicationServerThread,5,applicationServerThreadGroup]</PROCESS_ID>
    <USER_ID>oracle</USER_ID>
    </HEADER>
    <PAYLOAD>
    <MSG_TEXT>[ RM ] Exception in repository API getDBConnect()</MSG_TEXT>
    <SUPPL_DETAIL><![CDATA[oracle.ias.repository.schema.SchemaException: Unable to connect to Directory Server:javax.naming.CommunicationException: oracleportal.peesh.com:389 [Root exception is java.net.ConnectException: Connection refused]
         at oracle.ias.repository.directory.DirectoryReader.connect(DirectoryReader.java:104)
         at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:243)
         at com.evermind.util.ThreadPoolThread.run(ThreadPoolThread.java:64)
    ]]></SUPPL_DETAIL>
    </PAYLOAD>
    </MESSAGE>

    The <url-pattern> tells the application server which requests are to be handled by the FacesServlet. If the requested URL matches, then the FacesServlet handles the request.
    This parameter is not specific to JSF.

  • ESB_HOME error in log.xml after installation

    What is that magic failed to get ESB_HOME: java.lang.NullPointerException
    in log.xml file after installing SOA Suite package?
    ESB Console also shows s empty service list.
    I have tried couple of times to reinstall Suite with Basic install but nothing helps.
    Anyone knows this error issus?
    Cheers.

    Hello
    I've solved the problem.
    In the stack.xml file are multiples software-components with the same name, here "SERVERCORE".
    I had 3 entries, two with patch-level 0 and one with patch-level 1.
    I've deleted the two entries with patch-level 0 and then it works.
    Regards Christian

  • ADF Logger - logging.xml file

    Hi,
    We are building an ADF Application and created our logger, which is a wrapper around the ADFLogger. As expected logging etc works just fine for the ADF applications deployed in weblogic. However there are parts of the application which could be a standalone (pure java) based components deployed independently, which are leveraging this wrapper logger too. For these applications we added the ADF dependent libraries needed for the ADFLogger. Still these apps are not able to log anything, and I think the main reason being it is not able to get a handle to the logging.xml fine which defines the ODL handler. All other runtime parameters like
    "-Djbo.debugoutput=adflogger -Djbo.adflogger.level=FINEST" are passed.
    There is no error etc, however the logs are not coming.
    Is there a way where we can specify the logging.xml to the ADFLogger, so that it doesn't looks for the default location under - '+/<domain>/config/fmwconfig/servers/DefaultServer+'?
    In general also (for pure ADF based applications), is there a way we can define the path of our logging.xml file, instead of using the default one?
    Would appreciate any help.
    Thanks
    Sachin

    Hi,
    While I appreciate your response, however the question I have is - 'can we have our own logging.xml?' If yes how do we pass the information of our logging.xml to ADFLogger, instead of using the default logging.xml.
    I know we can have our own logger handler defined within the logging.xml, but that is not what we are looking for. The ask is to have the option of having the path of logging.xml defined for ADFLogger.
    Thanks
    Sachin

  • Java logging questions - an example would really help

    We have taken over a project (i.e. we inherited someone else's code). I am relatively new to java. We would like to add debug messages or log messages to trace the application. Is there an easy way to insert debug messages and view the applicable log files?
    1.) I added the following code to add a debug message "log.error("Inside doResetPassword (" + userIdentification + ", " + newPassword + ")");"
    2.) Where is this log file located (what is the name of the log file)? Do I have to enable logging in Oracle? What are the steps to enable the logging? Is there a console that displays the log messages?
    Any help would be greatly appreciated ...
    Thanks,
    Mike
    public class AuthenticationListener implements Listener {
    private static final Log log = LogFactory.getLog(AuthenticationListener.class);
    PersonnelService personnelService;
    EmailService emailService;
    * Setter for Spring injection of {@link EmailService}.
    * @param emailService
    public void setEmailService(EmailService emailService) {
    this.emailService = emailService;
    * Setter for Spring injection of {@link PersonnelService}.
    * @param personnelService
    public void setPersonnelService(PersonnelService personnelService) {
    this.personnelService = personnelService;
    public void doResetPassword(String userIdentification, String newPassword) {
    Personnel personnel = personnelService.loadPersonnelById(Integer.parseInt(userIdentification));
    log.error("Inside doResetPassword (" + userIdentification + ", " + newPassword + ")");
    try {
    emailService.send(new PasswordEmail(personnel, newPassword));
    } catch (Exception e) {
    log.error("AuthenticationListener.doResetPassword: " + e.getMessage());
    }

    Hi,
    You should check out log4j. It's pretty easy to use, and has been the favorite logging tool for pretty much everyone I've worked with for the last few years. It's free, just google it.
    You won't have to change your java code, it plugs into the standard Java logging facility automatically.
    You just put log4j.jar and log4j.xml into your applib directory. Here is an example of a log4j.xml file that logs both to the console and to the file /logs/my.log. It assumes your code is in 'com.mypackage.' You can have as many logger elements as you want, and have different packages or classes set to different logging levels.
    <pre>
    <?xml version="1.0" encoding="UTF-8" ?>
    <!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
    <log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
         <appender name="console" class="org.apache.log4j.ConsoleAppender">
              <param name="Target" value="System.out" />
              <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p %C %m%n" />
              </layout>
         </appender>
         <appender name="file" class="org.apache.log4j.RollingFileAppender">
              <param name="File" value="/logs/my.log" />
         <param name="Append" value="true" />     
              <layout class="org.apache.log4j.PatternLayout">
                   <param name="ConversionPattern"
                        value="%d{HH:mm:ss,SSS} %-5p %c %m%n" />
              </layout>
         </appender>
         <logger name="com.mypackage">
              <level value="debug" />
         </logger>
         <root>
              <priority value="warn" />
              <appender-ref ref="console" />
              <appender-ref ref="file" />
         </root>
    </log4j:configuration>
    </pre>
    Hope that helps,
    Mike from Ottawa

  • SOA log.xml error

    Unable to dispatch JSP Page : Exception:java.io.FileNotFoundException: /soad/app/soadas/10gAS/j2ee/home/applications/orabpel/console/default/index.jsp
    On top of this we also have an error "Unable to connect to repository" Are these related or two seprate errors? what should i look in to solve them
    log.xml file is where i retrieved these from
    Cause im trying to get an ESB running is like an old BPEL project causing this error? how can i get rid of the BPEL project in whatever text file this is saying the BPEL project is failing?
    Message was edited by:
    vande

    Please see if the following docs help.
    Discovery of IBM Websphere 6.1.0.21 in Grid Control fails with SOAP Exception in javax.net.ssl.SSLHandshakeException [ID 882752.1]
    "java.io.IOException: Invalid keystore format" and "java.security.NoSuchAlgorithmException" Seen During Weblogic Server Startup After Specifying a Keystore [ID 1453174.1]
    java.net.SocketException Failure In SOA When SSL Is Turned On [ID 1487792.1]
    Thanks,
    Hussein

  • Logging.xml

    how could i specify the Custom formatter and handler at logging.xml?
    While controlling programmatically, the logger works great and I am getting the perfect log as expected.
    How can I do that at design time? I tried in one of the way, here even the file has not been creating it.
    In a programmatic way i was able to do it, here i given the example
    public static void log(final Level level, final Class obj, final String method, final String message, final Object... params)
    FileHandler cfh;
    try
    cfh = new FileHandler("E:\\11.3\\Oracle\\jdev\\system11.1.1.3.37.56.60\\DefaultDomain\\servers\\DefaultServer\\logs\\mylog.txt");
    cfh.setFormatter(new java.util.logging.SimpleFormatter());
    cfh.setLevel(level);
    ADFLogger aDFLogger = ADFLogger.createADFLogger(obj);
    aDFLogger.addHandler(cfh);
    aDFLogger.logp(level, obj.getName(), method, message);
    aDFLogger.entering(obj.getClass().getName(), method, message);
    catch (IOException e)
    Here the sample ouput:
    Aug 12, 2010 4:27:40 PM org.as.queries.OfficeEventVOImpl About to call service, AS0100F
    FINE: Entering ...
    Aug 12, 2010 4:27:40 PM org.as.queries.OfficeEventVOImpl About to call service, AS0100F
    PERF: Entering ... About to call service, AS0100F
    "54N     " "SERVER ID     " "USERID     " "AS0100N     " "Web: OfficeEventVOImpl.retArrayFromService():AS0100F     " "Start Time : 08/12/2010 16:27:40"
    My try with logging.xml which didn't even created a file.
    <log_handler name='perf-handler' class='java.util.logging.FileHandler' formatter='java.util.logging.SimpleFormatter' level='ALL'>
    <property name='path' value='${domain.home}/servers/${weblogic.Name}/logs/perf.log'/>
    <property name='maxFileSize' value='10485760'/>
    <property name='maxLogSize' value='104857600'/>
    <property name='encoding' value='UTF-8'/>
    </log_handler>
    <logger name='org' level="ALL">
    <handler name='perf-handler'/>
    </logger>

    Arun,
    I played around a bit with your test case and it reproduces. I surmise the following:
    logging.xml is the configuration file for the Oracle Diagnostic Logger, and as such, I infer (it doesn't seem to be documented anywhere) that you can only use the ODL handlers in there (I was able to use other formatters). The logging.properties file (in jre/lib) can use the standard handlers. What I did was to use the ADFLogger in my code - if I configure logging.properties with a file handler, the log message shows up in all of the ODL logging places as well as in the file specified in my FileHandler.
    So, although it doesn't appear to be documented anywhere that I can find, if you want to use non-ODL handlers, you can configure them in the standard java.util.Logging configuration file, logging.properties.
    John

  • Java Log

    Hello Everyone,
    I found this example at this link: http://www.idevelopment.info/data/Programming/java/logging/LoggingDemo2.java
    import java.util.logging.*;
    import java.io.*;
    * Simple demo that uses the Java SDK 1.4 Logging API
    * @version 1.0
    * @author  Jeffrey M. Hunter  ([email protected])
    * @author  http://www.idevelopment.info
    public class LoggingDemo2 {
        private static Logger         logger   = Logger.getLogger("info.iDevelopment.MyLogger");
        private        ConsoleHandler console  = null;
        private        FileHandler    file     = null;
        public LoggingDemo2() {
            // Create a new handler to write to the console
            console = new ConsoleHandler();
            // create a new handler to write to a named file
            try {
                file = new FileHandler("LoggingDemo2.xml");
            } catch(IOException ioe) {
                logger.warning("Could not create a file...");
            // Add the handlers to the logger
            logger.addHandler(console);
            logger.addHandler(file);
        public void logMessage() {
            // Log a message
            logger.info("I am logging a test message...");
        public static void main(String [] args) {
            LoggingDemo2 demo = new LoggingDemo2();
            demo.logMessage();
    } The thing is it keeps creating the new LoggingDemo2.xml I want the message to be appended to the logger, not creating new file from time to time. Can someone please help me? Thanks.

    Use this constructor:
    <code>*FileHandler*(String pattern,
    boolean append)</code>
    ie.
    file = new FileHandler("LoggingDemo2.xml", true);

  • Error in the log.xml

    Dear oracles gurus,
    cannot understand the log file which has been generate when I start the listener I start the listener doing this
    [root@rac1 admin]# su - oracle
    [oracle@rac1 ~]$ lsnrctl start
    LSNRCTL for Linux: Version 11.1.0.6.0 - Production on 07-OCT-2007 02:55:15
    Copyright (c) 1991, 2007, Oracle. All rights reserved.
    Starting /u01/app/oracle/product/11.1.0/db_1/bin/tnslsnr: please wait...
    TNSLSNR for Linux: Version 11.1.0.6.0 - Production
    System parameter file is /u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
    Log messages written to /u01/app/oracle/diag/tnslsnr/rac1/listener/alert/log.xml
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.westernsolution.co.uk)(PORT=1521)))
    Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
    STATUS of the LISTENER
    Alias LISTENER
    Version TNSLSNR for Linux: Version 11.1.0.6.0 - Production
    Start Date 07-OCT-2007 02:55:17
    Uptime 0 days 0 hr. 0 min. 0 sec
    Trace Level off
    Security ON: Local OS Authentication
    SNMP OFF
    Listener Parameter File /u01/app/oracle/product/11.1.0/db_1/network/admin/listener.ora
    Listener Log File /u01/app/oracle/diag/tnslsnr/rac1/listener/alert/log.xml
    Listening Endpoints Summary...
    (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
    (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1.westernsolution.co.uk)(PORT=1521)))
    The listener supports no services
    The command completed successfully
    [oracle@rac1 ~]$
    the show that the listener is connected but infact their are no listener because when I check my log.xml it says
    <msg time='2007-10-07T02:41:05.792+01:00' org_id='oracle' comp_id='tnslsnr'
    type= 'UNKNOWN' level='16' host_id='rac1.westernsolution.co.uk' <----------------
    host_addr='192.168.122.1'>
    <txt>07-OCT-2007 02:41:05 * (CONNECT_DATA=(CID=(PROGRAM=)(HOST=rac1.westernsolution.co.uk)(USER=oracle))(COMMAND=status)(ARGUMENTS=64)(SERVICE=listener)(VERSION=185599488)) * status * 0
    </txt>
    </msg>
    I really do not understand why it says 'UNKOWN' . I think I have leave a mistake here.
    to confirm that my listener is not working I have created a database link and the result are as follows
    root@rac1 admin]# sqlplus
    bash: sqlplus: command not found
    [root@rac1 admin]# su - oracle
    [oracle@rac1 ~]$ sqlplus
    SQL*Plus: Release 11.1.0.6.0 - Production on Sun Oct 7 03:03:19 2007
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    Enter user-name: system/manager
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    SQL> select * from emp@local;
    select * from emp@local
    ERROR at line 1:
    ORA-12541: TNS:no listener
    SQL>
    Please any body can help me to find out what done wrong with the listener by observing the out I have paste above
    Regards
    sallil chudoory

    please close this tar I got the solutionLOL -
    This was not a TAR. This was a discussion with the volunteers (mostly non-Oracle employees at that) who use Oracle and are willing to help others.
    If this was a TAR, you would have been paying someone for the solution.

  • How to output java logging only to a log file except stderr?

    I create a file logging and noticed that java logging output a log file and stderr simultanously. How to output the logging message only to the log file?
    Thanks.

    HarishDv wrote:
    I dont have indesign  installed on my system. I only have the binary , which needs modification and i have to save back to the DB as indd.
    Can't be done, for a realistic assessment of "can". InDesigns documents cannot reliably be created or modified without InDesign itself. (*)
    If you need to do this on native InDesign documents, you have to buy and install it.
    * "Not true, there is always IDML". But that's not a 'binary'; and you cannot (**) "convert" a binary INDD to IDML and back again without InDesign.
    ** Again, for a remotely realistic value of "can".

  • Differnce between java script xml dom and Java Xml dom

    Hi,
    In my application For client side in Java Script for craetion of DOM MIcrosoft Activex object is used. USing that one they are buiidng DOM. And they are saving as XML. In server side i have to write one servlet which will parse that xml and i have to store in dynamic arrays.Which API is better for parsing XML in java.In util pacakge which class is better for storing dynamical values that means MAP,Hash Map,Hash table ??

    in java, the java..xml.parsers package is generally used for parsing xml into a DOM. there are also sax and stax parsers available.
    which class in java.util is better for storing stuff depends on what you need to do with the stuff. find a nice tutorial on java collections and then decide which one makes sense for what you need.

  • Java Logging in OC4J

    I use the Java Logging API in several web applications. Now I need to deploy these applications to OC4J.
    In the standalone version of OC4J 10.1.3 I can the log messages in the console. But I would like to see the log messages in the Enterprise Manager.
    In the Enterprise Manager there is an application.log file for each web application. How can I direct my java logging messages to these files? Or something similar so that I can browse/search the log messages in the Enterprise Manager ?
    I have tried to read everything I can find on the OTN web site. The developers guide has something on logging, but I can not get it to work.
    Can anyone please provide me with some glues/guidelines/short example on how I can get this to work?

    Onw way of writting to these files is to use the log methods in GenericServlet (inherited by HttpServlet):
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/GenericServlet.html#log(java.lang.String)
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/GenericServlet.html#log(java.lang.String, java.lang.Throwable)
    or these log methods in ServletContext:
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#log(java.lang.String)
    http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/ServletContext.html#log(java.lang.String, java.lang.Throwable)
    I have done this succesfully.
    Chris

  • Out of memory detected in log.xml

    Hi,
    Our db version is 11.1.0.7.0 and in log.xml we see out of memory error like this
    Out of memory detected in /u01/app/oracle/admin/diag/rdbms/ABCD/alert/log.xml at time/line number: Tue Feb 15 03:09:11 2011/54933.
    Alert log file looks ok.
    How to prevent this?

    You need to provide more information than that. I presume you got this from the OEM alert.
    Try looking in /u01/app/oracle/admin/diag/rdbms/ABCD/ABCD/trace/alert_ABCD.log and look at any entries for February 15th. That might point you in the right direction.

  • What is better Java Logging or Log4J?

    What is better Java Logging or Log4J and why?

    for my money, log4j has the edge, largely because it doesn't keep a lock on log files when they're not actually being written to. but on the downside, it's another third-party library you have to use. then again, every project I've worked on recently has had it imported anyway via some other third-party library like Spring or Hibernate, so it's there anyway
    but only you can answer "which is more suitable for me"

  • Help with Java to XML

    All I need to know is how to bold the tag <CompanyID> </CompanyID> OR the text within it (1001, in given sample).
    Here's a sample line of the data.txt file I'm working with:
    1001,"Fitzsimmons, Des Marteau, Beale and Nunn",109,"COD","Standard",,109,8/14/1998 8:50:02
    Thanks in advance!
    public class PracticeExerciseOne {
        public static void main(String [] args){
            DocumentBuilderFactory domFac = null;
            DocumentBuilder domBuild = null;
            //Element tags
            final String COMPANY = "Companies";
            final String COMPANY_ID = "CompanyID";
            //rest too long to post
            //Regex to be used for each field in the CSV file
            ArrayList<Pattern> patterns = new ArrayList<Pattern>();
            patterns.add(Pattern.compile("[0-9]+,"));
            patterns.add(Pattern.compile("\".+?\","));
            patterns.add(Pattern.compile("[0-9]+,"));
            patterns.add(Pattern.compile("\".+?\","));
            patterns.add(Pattern.compile("\".+?\","));
            patterns.add(Pattern.compile("[^,]*,"));
            patterns.add(Pattern.compile("[0-9]+,"));
            patterns.add(Pattern.compile("[^,]+ [^,]+"));
            //Store element tags in an array - too long to post
            try{
                //Build a new documet
                domFac = DocumentBuilderFactory.newInstance();
                domBuild = domFac.newDocumentBuilder();
                Document doc = domBuild.newDocument();
                //Create a new root element
                Element rootElement = doc.createElement(COMPANY);
                doc.appendChild(rootElement);
                //Read in the file
                BufferedReader in = new BufferedReader(new FileReader(new File("texts/data.txt")));
                BufferedWriter out = new BufferedWriter(new FileWriter(new File("texts/dataOut.xml")));
                int tempI;
                String line = in.readLine();
                //We will cut this string down after every element we take out of it
                String temp = line;
                String tempElement = "";
                while(line != null){
                    for(int i = 0; i < patterns.size(); i++){
                        //Matches a pattern to a field, starting with the first pattern
                        //Matchup should be 1st pattern = 1st field
                        Matcher matcher = patterns.get(i).matcher(temp);
                        if(matcher.find()){
                            //if we haven't reached the last field
                            if(i != 7){
                                //we want to get the index of the last comma within the matched group
                                tempI = matcher.group().lastIndexOf(',');
                                //create an element using the beginning of the given string and the last comma within that data
                                tempElement = temp.substring(0,tempI);
                            else{
                                //no comma in last field, so we just want to get the whole field
                                tempI = 0;
                                tempElement = temp.substring(0);
                            //if an empty element appears, add a space for tags to be placed correctly
                            if(tempElement.equals("")){
                                tempElement = " ";
                            //temp will be set to the remaining string, once we have taken the nth field out
                            temp = temp.substring(tempI+1);
                            //create an element with tags and append to document
                            Element em = doc.createElement(tags);
    em.appendChild(doc.createTextNode(tempElement));
    rootElement.appendChild(em);
    line = in.readLine();
    temp = line;
    //Transformer will create a new XML document using the Document we have built
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
    Transformer transformer = transformerFactory.newTransformer();
    transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");
    transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    DOMSource source = new DOMSource(doc);
    StreamResult result = new StreamResult(out);
    transformer.transform(source, result);
    out.close();
    in.close();
    catch(Exception e){
    System.err.println("Exception: " + e.getMessage());
    e.printStackTrace();

    maybe this can help You for now and future,
    in this site You can download a sample codes publish in this books - java fundamentals and advanced features.,
    in 2nd book, is a big chapter about java and xml. Please read this code, i will hope, this can help You.
    http://www.horstmann.com/corejava.html (for mod: this is not SPAM)

Maybe you are looking for

  • Re: how to get apps for iphone 3g 4.2.1

    Re: how to get apps for iphone 3g 4.2.1 all apps support higher version help.... Sep 24, 2013 6:34 AM (in response to Rajmit) I still have an old 3G which I use mostly as a ipod/radio. By accident I found you can overide the i-tunes block. 1. Select

  • Linking between two Logic Pro machines for recording...

    I am working on a film overseas where I need to run two Macs recording live concerts to Logic Pro simulatinously. How do I effectivly sync these two machines in a master/slave set-up? Can I use MMC, or is there a different protocol?

  • WEB-INF bug?

    Hi, I've noticed one strange thing on the iAS SP3 Test Drive. Let's assume, I have a servlet MyServlet, URL is http://hostname/NASApp/MyServletContext/MyServlet, Servlet class is MyServlet.class in package com.mycompany.servlets. I can download the s

  • How do I cascade Mozilla windows in Windows 7 desktop

    In older versions when many Firefox windows were open, the option to cascade the windows was available. On this PC with Windows 7 this option seems to have disappeared. Also, it used to be possible to close all Firefox windows at once, and now they h

  • OCI client notification without a AQ queue

    Hi Forum, Well, put it in the simplest manner, I want to run a perl script when a Insert trigger occurs. And I was wondering if it is possible that a OCI client be notified, when a trigger occurs, without using a AQ queue ? I ask that because in Orac