![]() |
| ||
| Extract field from text file Hello all, I wondering if anyone could tell me how to go about extracting a single field from a text file. The file is all follows: Jeff 8.00 8.9900 hadk Kim 234.0 234 hak Him 444.8 1.11 john... How would I extract only the first column without using tokenizer or split? Thank you, |
| ||
| Re: Extract field from text file Serialilzation is solution to your question. Try to read this tutorial from Java How to Program |
| ||
| Re: Extract field from text file I have never heard of serialization but I will read the tuturial and give it a try. In the mean time, would parsing a text file work? If so, how would I go about achieving the desired results? Thanks |
| ||
| Re: Extract field from text file I can't see why you need to avoid split, but Scanner and java.util.regex are other options for parsing your input. |
| ||
| Re: Extract field from text file Thanks so much. This is a big help. |
| ||
| Re: Extract field from text file If you can't use split I doubt regex would be considered a viable alternative. It more or less does the same thing behind the scenes. Maybe you should just google what other options you can use from the string class, such and find() and substring()? |
| ||
| Re: Extract field from text file you can use FileReader... here is the documentation for j2se 5: http://java.sun.com/j2se/1.5.0/docs/...ileReader.html |
| ||
| Re: Extract field from text file > Serialilzation is solution to your question. Serialization is a completely different beast. In serialization, you serialize i.e. persist an object onto the secondary storage and read them again as and when required. Here the user is presented with a simple text file so the only option is to read the file using the File streams or readers and parsing the content as required. |
| All times are GMT -4. The time now is 5:22 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC