• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Why is my string still writing data to my file that i've asked it not to?

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically i have a program to read in the contents of a folder and capture instances of a substring stored between two strings. I want the instances of the substring called "resourceline" to be stored within an array and then sorted and printed into a new document.

However i only want the instances to be stored IF they dont already exist and if the string does not contain certain symbols. I am doing this because i get too much irrelevant data come accross.
The problem is the progam is working but still writing data that i dont want.

please help
regards S

my code is below

 
Ranch Hand
Posts: 151
MyEclipse IDE Python Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
provide one example what you are providing the input, what it gives the output and what you want to desire from this code ........
 
Ranch Hand
Posts: 198
Oracle Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Use && in place of || and check. Hope it works fine now.

 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Prabhakar Reddy Bokka wrote:Use && in place of || and check.


No, that would mean the "blank" code would execute only if *all* of the conditions are met; my understanding is that if *any* of the characters are found it's a match.

(I realize it's hard to tell because of the strange nature of the code.)
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Nick: Again--PLEASE post compilable code. There are three errors in this source.
 
author and iconoclast
Posts: 24203
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I see it, this should follow your requirement about duplicates, but ignore your requirement about special characters. There are two completely unconnected conditionals: the first one, "if (checkContains1...", controls access to an empty block, so it does absolutely nothing. Then the next conditional is tested regardless of the outcome of the first. It checks for duplicates, and otherwise then adds the line to the list.

If your "checkContains" check had a "continue" in it, or if it was attached to the later conditional with an "else", then we'd be getting somewhere.
 
The happiness of your life depends upon the quality of your thoughts -Marcus Aurelius ... think about this tiny ad:
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic