Thanks for this. Been coding for many years, but always come back here to refresh my memory. And I did buy your book too. Just that this is easier to search.
3 Mar 2010 - 9:55am by Anonymous (not verified)
Process doesnt work for my program!
5 Mar 2010 - 1:29pm by Jone (not verified)
Thanx...
6 Mar 2010 - 6:08am by Ollie (not verified)
Do you have to import anything for this to work?
18 Mar 2010 - 5:16am by Anonymous (not verified)
I'm not familiar with this site but I think anything with italic blue text (infilename and process(str)" is meant to be pseudocode, aka replaced with the actual code for your specific needs.
The "process(str)" is basically pseudocode for whatever you want to do with the incoming text; literally it means "here is where you process the string.
Replace "process(str);" with something like "vector.add(str);" or "array[x] = str;", basically customize it to your needs.
Hope this helps.
21 Mar 2010 - 4:22pm by Anonymous (not verified)
thankyou
4 Apr 2010 - 11:56am by Anonymous (not verified)
what if i want to read the text file word by word?
4 Apr 2010 - 12:09pm by Anonymous (not verified)
what about reading a text file line by line?
14 Apr 2010 - 10:08am by Anonymous (not verified)
prev commenter: this program *does* read the file line by line. in.readLine() reads a line. if you want to handle words, split the line on spaces using String.split() - see the java.util.regex/ParseLine.html example here at Example Depot
26 Apr 2010 - 5:23am by Anonymous (not verified)
Shouldn't the in.close() be in a finally block? If an IOException occurs won't the file be left open?
12 May 2010 - 10:46pm by AlexV (not verified)
Note that that would use the default encoding. To specify a particular encoding do this:
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-16"));
You can use "ASCII", "UTF-8", etc...
26 May 2010 - 7:37am by Anonymous (not verified)
I need a little help here. I need to Develop an application that reads c:/listings.txt file, analyzes the properties listed, and outputs an overview of properties listed to an overview.txt file.
1. Prompt the user for the name of the input file (listings.txt).
2. Open the listings.txt file and read in property listing information using a buffered FileReader.
3. Count the total number of property listings for sale.
• Use buffered FileWriter to write the count of the number of property listings to your overview.txt file.
4. Calculate the total value of property for sale.
• Use a buffered FileWriter to write the total value of properties currently for sale.
5. Store each property id into an ArrayList.
a. Sort the ArrayList of property ids using natural ordering.
b. Use a for-each loop to iterate through the sorted ArrayList and write property ids to overview.txt file using buffered FileWriter.
6. Use buffered FileWriter to write the total value of the properties listed and the total number of properties currently for sale.
Could anyone offer some guidence this. I'm new to programming and it's a bit overwhelming.
26 May 2010 - 7:42am by Anonymous (not verified)
This is what is in the listings file in order by prop ID, propType, propertyValue and AgentId:
110001 commercial 500000.00 101
110223 residential 100000.00 101
110020 commercial 1000000.00 107
110333 land 30000.00 105
110442 farm 200000.00 106
110421 land 250000.00 110
good example.
It is really nice that I knew buffered reader.
Simple and good example.
I need more help with this.
thanks exactly what i needed
Thanks for this. Been coding for many years, but always come back here to refresh my memory. And I did buy your book too. Just that this is easier to search.
Process doesnt work for my program!
Thanx...
Do you have to import anything for this to work?
I'm not familiar with this site but I think anything with italic blue text (infilename and process(str)" is meant to be pseudocode, aka replaced with the actual code for your specific needs.
The "process(str)" is basically pseudocode for whatever you want to do with the incoming text; literally it means "here is where you process the string.
Replace "process(str);" with something like "vector.add(str);" or "array[x] = str;", basically customize it to your needs.
Hope this helps.
thankyou
what if i want to read the text file word by word?
what about reading a text file line by line?
prev commenter: this program *does* read the file line by line. in.readLine() reads a line. if you want to handle words, split the line on spaces using String.split() - see the java.util.regex/ParseLine.html example here at Example Depot
Shouldn't the in.close() be in a finally block? If an IOException occurs won't the file be left open?
Note that that would use the default encoding. To specify a particular encoding do this:
BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(fileName), "UTF-16"));
You can use "ASCII", "UTF-8", etc...
I need a little help here. I need to Develop an application that reads c:/listings.txt file, analyzes the properties listed, and outputs an overview of properties listed to an overview.txt file.
1. Prompt the user for the name of the input file (listings.txt).
2. Open the listings.txt file and read in property listing information using a buffered FileReader.
3. Count the total number of property listings for sale.
• Use buffered FileWriter to write the count of the number of property listings to your overview.txt file.
4. Calculate the total value of property for sale.
• Use a buffered FileWriter to write the total value of properties currently for sale.
5. Store each property id into an ArrayList.
a. Sort the ArrayList of property ids using natural ordering.
b. Use a for-each loop to iterate through the sorted ArrayList and write property ids to overview.txt file using buffered FileWriter.
6. Use buffered FileWriter to write the total value of the properties listed and the total number of properties currently for sale.
Could anyone offer some guidence this. I'm new to programming and it's a bit overwhelming.
This is what is in the listings file in order by prop ID, propType, propertyValue and AgentId:
110001 commercial 500000.00 101
110223 residential 100000.00 101
110020 commercial 1000000.00 107
110333 land 30000.00 105
110442 farm 200000.00 106
110421 land 250000.00 110
thanks !