By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,983 Members | 2,035 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,983 IT Pros & Developers. It's quick & easy.

how to read multiple (binary) lines from text file / stdin?

P: n/a

hi group!
i am writing a small tool to dump data from oracle databases and i want
to implement the possibility to execute sql statements read from stdin
or from a file. i have so far managed to do so, but every sql statement
must be on a single line with no ";" at the end of each line.

i would like to use an input file like this:
-- file statement.sql --
select * from table
where thing = "something";
------------------------
or

-- file statement.sql --
update table
set image = '<binary data>'
where thing = otherthing;
------------------------

this is how the code looks so far:
// code start

BufferedReader in = new BufferedReader(new FileReader(filename));

while (((statement=in.readLine())!= null) &&(!statement.equals(""))){
try {
ResultSet rset = stmt.executeQuery(statement);
[...]
}
}

// code end
i would like 'statement' to contain the multiline sql statement
including all newlines so that also binary data may be inserted into the
db so i tried to use

System.setProperty("line.separator", ";");

but that didn't help and also doesn't seem the right way for what i want
to achieve. could someone please point me into the right direction on
how to do that? the variety of different stream classes is somewhat
confusing in terms of finding the right class for the right job.
big TIA, armin
--
armin walland

focusmr.com
maculangasse 8
1220 wien
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
armin walland <ge******@gmx.at> wrote in message news:<sl*********************@armin.focusmr.co.at> ...
hi group!
i am writing a small tool to dump data from oracle databases and i want
to implement the possibility to execute sql statements read from stdin
or from a file. i have so far managed to do so, but every sql statement
must be on a single line with no ";" at the end of each line.


Take a look at the StreamTokenizer class in java.io . It is quite
daunting for beginners, so you might want to Google around for a good
tutorial on how to use it. It is designed to parse language source
code, and has a few handy in-built features for handling comments and
string literals, etc.
-FISH- ><>
Jul 17 '05 #2

P: n/a
On 2004-01-27, FISH <jo*****@merseymail.com> wrote:
armin walland <ge******@gmx.at> wrote in message news:<sl*********************@armin.focusmr.co.at> ...
i am writing a small tool to dump data from oracle databases and i want
to implement the possibility to execute sql statements read from stdin
or from a file. i have so far managed to do so, but every sql statement
must be on a single line with no ";" at the end of each line.


Take a look at the StreamTokenizer class in java.io . It is quite
daunting for beginners, so you might want to Google around for a good
tutorial on how to use it. It is designed to parse language source
code, and has a few handy in-built features for handling comments and
string literals, etc.


thanx a lot :)
rgds, armin
--
armin walland

focusmr.com
maculangasse 8
1220 wien
+43 (0)1-258 97 01 291

Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.