IOException while accesing files
Hi iam trying to read a file and write the contents into another file present in other directory.Iam using the following method
Code Java:
public static void storeFile(String fileName, String fileContents){
BufferedWriter writer = null;
if (log.isDebugEnabled())log.debug("File name to store" + fileName);
System.out.println("This is from FileOperations----storeFile()-----filename to store "+fileName);
try {
FileWriter fileWriter = new FileWriter(fileName);
writer = new BufferedWriter(fileWriter);
System.out.println(writer);
writer.write(fileContents, 0, fileContents.length());
System.out.println("This is from File operations-----------------------4");
}
catch (IOException ex) {
System.out.println("This is from IOEXception===========");
ex.printStackTrace();
}
finally {
try {
writer.close();
}
catch (IOException ex) {
System.out.println("This is from finally ------");
ex.printStackTrace();
}
}
}
iam getting the following output
This is from FileOperations----storeFile()-----filename to store D:/Australia/T
VETL/Transform/Transform/trunk/ETLFileStore/ETLOutputs/Output \CAPVOLMARKETDATA
HISTORICAL-11292011_11267.xml
This is from File operations-----------------------1
This is from File operations-----------------------2
This is from IOEXception===========
can anyone help me to solve this .....................?
Re: IOException while accesing files
And how do you need the help? What is the problem with your above code and what do you expect it to do? We can't read minds though.
Re: IOException while accesing files
We are probably going to have to see all of your code. Can you also post the full StackTrace.
Are you sure the path to your file is correct?