473,320 Members | 2,000 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Program won't compile

I am writing a program to store stuff to xml using the storeToXML method
but I can;t get it to compile here it is; any ideas?


import java.io.*;

import java.util.*;

public class XmlWrite {

public static void main(String args[]) throws Exception {

try {

Properties props = new Properties();

props.setProperty("something", "bla");

props.setProperty("stuff", "brown and black");

props.setProperty("morestuff", "me");

props.setProperty("enablepassword", "yes");

props.setProperty("answer", "null");

String OperatingSystem = System.getProperty("user.home") +"\\";
FileOutputStream xmlwrite =
new FileOutputStream(OperatingSystem + "config.xml");

props.java.util.Properties.storeToXML(xmlwrite, "config");

xmlwrite.close();
}

// if writing to the specified output stream results in an
IOException

catch (IOException e) {

//Print system error

System.err.println("An Error Occured While Writing To The
File");
}

// if os is null.

catch (NullPointerException e) {

//Print system error

System.err.println("OS Value is Null");

}

}

}
Jul 17 '05 #1
2 1937
1. "props.java.util.Properties.storeToXML(xmlwrit e, "config")" does not make
any sense - not to the compiler, not to myself.

2. NullPointerException should never be caught. Instead, your code should
check for null values and _prevent_ the NPE from ever happening.

3. If you ask for help in debugging code, provide the full list of the
compiler errors, as generated by the compiler. Just saying "is does not
compile" won't get you any help.

"Gary Redmond" <gr@iol.ie> wrote in message
news:KH*******************@news.indigo.ie...
I am writing a program to store stuff to xml using the storeToXML method
but I can;t get it to compile here it is; any ideas?


import java.io.*;

import java.util.*;

public class XmlWrite {

public static void main(String args[]) throws Exception {

try {

Properties props = new Properties();

props.setProperty("something", "bla");

props.setProperty("stuff", "brown and black");

props.setProperty("morestuff", "me");

props.setProperty("enablepassword", "yes");

props.setProperty("answer", "null");

String OperatingSystem = System.getProperty("user.home") +"\\";

FileOutputStream xmlwrite =
new FileOutputStream(OperatingSystem + "config.xml");

props.java.util.Properties.storeToXML(xmlwrite, "config");

xmlwrite.close();
}

// if writing to the specified output stream results in an
IOException

catch (IOException e) {

//Print system error

System.err.println("An Error Occured While Writing To The
File");
}

// if os is null.

catch (NullPointerException e) {

//Print system error

System.err.println("OS Value is Null");

}

}

}

Jul 17 '05 #2
storeToXML is Java 5.0. You have to compile it with -source 1.5 (I think).
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: alphatan | last post by:
Is there relative source or document for this purpose? I've searched the index of "Mastering Regular Expression", but cannot get the useful information for C. Thanks in advanced. -- Learning...
6
by: tigrfire | last post by:
I've been working on a program to try and play a game of Craps, based on a version I found elsewhere - I didn't code the original, but I added a few things such as a balance and wager system. I'm...
2
by: Gabriel Hernandez | last post by:
Well I am just getting started with C++ and I am having a problem. I created a very simple program and when I try to compile it I receive this message Cannot compile the file 'C:\Program...
16
by: Martin Joergensen | last post by:
Hi, I wanted to try something which I think is a very good exercise... I read in data from the keyboard and store them in a structure. There's a pointer called "data_pointer" which I use to...
6
by: Howard Gardner | last post by:
/* As it sits, this program won't compile for me. It will compile using either of the versions of tpt that I've commented out. Which versions SHOULD compile? I think that the code is...
0
by: Tom | last post by:
I have a .net v2 asp.net problem. I develop on my workstation and deploy to a production server. I use compile on demand, so no pre-compile is done. When I deploy, I first must move in my new or...
10
by: Ron | last post by:
I've got this simple program that will not build or run, any idea what I am doing wrong? Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
21
by: AsheeG87 | last post by:
Hey Everyone~ I'm still a C++ Rookie so please bear with me on this. I'm doing a temperature conversion program with prototype functions. Basicly, I was wondering if some of you would take a look...
4
by: Billy | last post by:
Hi! I'm using: -Compiler: Borland Command Line C++ Compiler 5.5.1 -Code Editor: SciTE 1.75 Anybody know how we can in Scite with command Tools|Go (F5) compile and run my c or cpp program at...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.