• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

decrementing position in a file based on variable

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I read a file, test the contents to a variable in a while loop and if the contents differ. decrement the lines of the file to another variable and write a line of text on the line directly above the variable. e.g.


for(String line; (line = lrdr.readLine()) != null {
System.out.println(lrdr.getLineNumber() + ":\t" + line);
if(br.readLine().startsWith("0TRADER:") == true){
prevTrader = br.readLine().substring(19,22);
if(br.readLine().startsWith("1")){ onelineNo = lrdr.getLineNumber(); if(br.readLine().startsWith("0TRADER:") == true){ curTrader = br.readLine().substring(19,22); if(curTrader.compareTo(prevTrader) != 0){ --onelineNo; System.out.println("$DJDE FORMS=PARIB6 FORMAT=PARCIX DUPLEX=NO FEED=BLUE SIDE=(NUFRONT,NOFFSET) MODIFY=NONE END;");
[ October 27, 2006: Message edited by: Jim Yingst ]
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Harrell, I've taken the unusual step of removing the [ code ] tags from your post. The reason being, your post had no line breaks and was far too wide to read comfortably. Unfortunately this would also force all other posts on this page to be just as wide, so it's not something we can just ignore. Normally I would just fix the formatting a little bit, but in this case there were too many typos; I couldn't tell what you were really trying to do. Please edit your post to include some sort of readable formatting, and then put in the [ code ] tags again. Thanks.
[ October 27, 2006: Message edited by: Jim Yingst ]
reply
    Bookmark Topic Watch Topic
  • New Topic