Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

file format changed by Java

Status
Not open for further replies.

cobweb

IS-IT--Management
May 5, 2002
95
GB
Hello there:
I have written my first Java utility which looks at a csv file of payment instructions, makes changes if I want, and saves it.
The problem is that the changed file cannot be read by the bank program- opened in notepad the end of lines appear all wrong.
I have looked through your search facility but can find nothing.I have found a utility ("EOL Converter") which can do this ( so it is recognised!)but I want to incorporate the solution - for a predetermined source and destination file - into my utility.
Can anybody please advise?

Thanks!
 
What kind of data - ASCII or binary ?

What do you mean by "the end of lines appear all wrong" ? How exactly - what do you expect, what do you get ?

How are you creating the file ? What IO objects ? How are you writing "new lines" - are you using a CRLF ?

These are questions that will help us help you !

--------------------------------------------------
Free Database Connection Pooling Software
 
Hi sedj:
It is a csv file created from a windows based accounting system.
It is a list of payees and their bank details.

My utility reads the file (written in JBuilder it uses JDatastore) as a grid, allowing me to delete accounts I do not want to pay.
The process of saving the file creates 'black blocks' at the end of the file.
The BACS payment system which is supposed to import the file does not recognise the layout.
I do not create the file or add new lines.
I found a utility on the internet which, when run, ' reformats ' the file. I understand that the failure of Java to save a file in the format appropriate to the operating system is well known - I just cannot write the utility!
Thanks!
 
Got it!
(Well, got it off the internet..thanks to Joseph A. Huwaldt)
This code takes a specified file (plbacs.csv) and converts it to something windows can read


try {
File inFile = new File("c:\\Waverly\\plbacs.csv");
File outFile = new File("c:\\Waverly\\payment.csv");
convertFile(inFile, outFile);
} catch (Exception k) {
System.err.println("An error occured converting the specified file.");
System.err.println(k.getMessage());
}

}


public static void convertFile(File inFile, File outFile) throws FileNotFoundException,
IOException {

BufferedReader bufferedreader = new BufferedReader(new FileReader(inFile));
BufferedWriter bufferedwriter = new BufferedWriter(new FileWriter(outFile));

String line;
while ((line = bufferedreader.readLine()) != null) {
bufferedwriter.write(line);
bufferedwriter.newLine();
}

bufferedreader.close();
bufferedwriter.close();
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top