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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reading a Text File

Status
Not open for further replies.

vvicin01

Programmer
Aug 14, 2001
21
0
0
US
I have a text file which has over 100 items listed that I would like to pull and pass to a servlet to query a database. Basically, I want to pull each line from the text, pass that value to a servlet, and then query an oracle database. For example:

Text file joe.txt contains:

apples
turtles
purple

Retrieve line 1 and pass it to a servlet:
String test = text1.txt

select * from msu where description = ' description here ' where msu.name = " + test ";

Here I would loop through the txt file and search for each item listed into the database.


Please help if you can.

Vic





 
Hi,
it is not clear what do you want.
Regards Boris
 
Try something like this:

LIST=`cat joe.txt`

for i in $LIST
do
<do something here, use $i to use each entry in the file called joe.txt>
done

Hope it helps

IBM Certified Confused - MQSeries
IBM Certified Flabbergasted - AIX 5 pSeries System Administration
 


This is for BASH, it may or may not work in other shells.

while read line x
do
`cmd to send to servlet`
done </text_file_reading_from


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top