Forums Register Login

add text to a .txt file

+Pie Number of slices to send: Send
Hi,
I am trying to write a small program that will allow me to read a txt file and append text to the end and beginning of each line.
cheers in advance
+Pie Number of slices to send: Send
tryiing using this method
public void write(String s, int off, int len)
It is part of the bufferedwriter class
take a look at the javadocs
+Pie Number of slices to send: Send
Hi, Mike! It's always good to see new first posts!

What have you tried and what's not working for you? If you have some code fragments (keep em small, and use the "code" button in the Ranch editor) we can look them over and see what's going on.
+Pie Number of slices to send: Send
I am just starting out java, mainly programme mainframe(procedural) but trying hard, I have large sql queries for payments done in query analyser but want a program to append the text 'query.append("' at the beginning of a line and of course ' ");' to the end of a line.

+Pie Number of slices to send: Send
That code doesn't compile. I think you have the "char" data type, which is a single character, confused with either an array of char's or a String object. You should get familiar with the Java Tutorial. Plenty of helpful information, like what Data Types are available and how to perform IO.
+Pie Number of slices to send: Send
How about this as a first stab?Caveat: if the read line contains any " characters, you'll need to escape them by preceding each one with a backslash (\). But it's time for bed so I'll leave that for you.
LOOK! OVER THERE! (yoink) your tiny ad is now my tiny ad.
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1681 times.
Similar Threads
need help
problem with insert and select
Applet Cache
path problem
getting error in programatically created pdf
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 15:26:25.