Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

How to ignore asserting text when comparing two files in java

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator



For Example:

expectedFile contains the following:

Hello my name is Jane Page 1
Hello my name is John Page 2
Hello my name is Jane Page 3
Hello my name is Jane Page 4

actualFile contains the following:

Hello my name is Jane Page 1
Hello my name is John Page 2
Hello my name is Jane Page 3
Hello my name is Jane Page 4

I want to ignore asserting Page 1 in each line, but assert the rest of the text inside the file.
 
Saloon Keeper
Posts: 7417
170
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not quite sure what you mean by "assert", but if the text lines contain parts that should not be compared then those should be removed before the comparison.
 
Ntsakisi Julia Mabaso
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Tim,

I am writing a test to compare two files (expected and actual), the problem was that I want to exclude Page number from the file.
So when I compare the two files, it should ignore Page number.
I will try your suggestions. Thanks
 
Marshal
Posts: 76472
366
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

Can you work out how to get the index of a certain text and then truncate the text at that point?
 
My, my, aren't you a big fella. Here, have a tiny ad:
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic