Problem with Java IO exception?
Hi, new to java and trying to access a file on my hard drive (Which exists at the address specified) but am getting an IO exception...
I an referening the file from class Engine into class DataAccess
Could someone have a look for me please
Many thanks
package StatPairsModel;
import java.io.IOException;
import java.util.Hashtable;
public class Engine {
public static void main(String[] arguments) {
Instrument stock1 = new Instrument();
Instrument stock2 = new Instrument();
//PROBLEM WITH NEXT LINE - IOException
DataAccess tsData = new DataAccess
("c:\PairsData\timeseries.txt");
stock1.setStock("0015425", "Vodafone", "VOD LN", "UK", "TELECOM",
"GBP", "VOD LN", "FTSE");
stock2.setStock("0045125", "Telecom Italia", "TIM IM", "IT", "TELECOM",
"EUR", "TIM IM", "MIB");
int i = 0;
}
}
package StatPairsModel;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Vector;
import java.util.Hashtable;
import java.util.StringTokenizer;
import java.util.Enumeration;
public class DataAccess {
// class MyClass extends java.util.Hashtable {
String address;
int dataPointCount = 0;
int dayCounter = 0;
DataAccess(String address)
throws IOException {
int requiredPriceFrom = 0;
int totalPricesRequired = 100;
String tempDateField = "";
String tempTickerField = "";
String thisLine;
Hashtable mnemonicMap = new Hashtable();
Hashtable idMap = new Hashtable();
Hashtable dateMap = new Hashtable();
Hashtable close_price_euroMap = new Hashtable();
Hashtable close_volumeMap = new Hashtable();
Hashtable close_mcapMap = new Hashtable();
Hashtable close_corp_actionMap = new Hashtable();
Hashtable betaMap = new Hashtable();
Hashtable close_price_localMap = new Hashtable();
{
try {
FileReader file = new FileReader(address);
BufferedReader buff = new BufferedReader(file);
String keyField = null;
int dateKeyField = 0;
int tickerKeyField = 0;
boolean eof = false;
while ((thisLine = buff.readLine()) != null && !eof) {
StringTokenizer st = new StringTokenizer(thisLine, ",");
dataPointCount = 0;
while (st.hasMoreElements()) {
dayCounter = 0;
for (int i = 0; i < 9; i++) {
String field = st.nextToken();
switch (i) {
case 0:
keyField = field + dayCounter;
System.out
.print(keyField + ", " + field + ", ");
mnemonicMap.put(keyField, new String(field));
break;
case 1:
System.out
.print(keyField + ", " + field + ", ");
tempTickerField = field;
idMap.put(keyField, new String(field));
break;
case 2:
System.out
.print(keyField + ", " + field + ", ");
tempTickerField = field;
dateMap.put(keyField, new String(field));
break;
case 3:
System.out
.print(keyField + ", " + field + ", ");
tempTickerField = field;
close_price_euroMap.put(keyField, new String(
field));
break;
case 4:
System.out
.print(keyField + ", " + field + ", ");
tempTickerField = field;
close_volumeMap
.put(keyField, new String(field));
break;
case 5:
System.out
.print(keyField + ", " + field + ", ");
tempTickerField = field;
close_mcapMap.put(keyField, new String(field));
break;
case 6:
System.out
.print(keyField + ", " + field + ", ");
tempTickerField = field;
close_corp_actionMap.put(keyField, new String(
field));
break;
case 7:
System.out
.print(keyField + ", " + field + ", ");
tempTickerField = field;
betaMap.put(keyField, new String(field));
break;
case 8:
System.out
.print(keyField + ", " + field + ", ");
tempTickerField = field;
close_price_localMap.put(keyField, new String(
field));
break;
}
}
dataPointCount++;
dayCounter++;
}
System.out.println();
dataPointCount++;
}
System.out.println("dataPointCount " + dataPointCount);
System.out.println("address " + address);
}
catch (IOException e) {
System.out.println("Error -- " + e.toString());
}
}
}
void process() {
System.out.println("Processing....");
}
|