• 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

how to pass the value from one string to another using the directory ?

 
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I have an directory file and there are so many files inside the directory. I want to pass the string from one class to another and get the result.

main for the directory file


class file name declared with main
input files in the Directory templates are 1.txt
NAME
REGISTER NUMBER
STANDARD
SCHOOL NAME

2.txt
STAFF ID
NAME
SALARY
EXPERIENCE

here i would like to make an pattern matching. if the directory file matches with 1.txt it should print the contents inside 1.txt.so for that i want to pass the file names to the Dircheck1 and get the result. The file name called here and stored in name text in the pattern matcher.

So i want to pass the file names from one to another and get the result. I hope i am clear in explaining. Guide me how to reach the desired output.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

deepika deepi wrote:I have an directory file...


Deepaki,

I broke up those enormous lines of yours. Please re-read the UseCodeTags page thoroughly before you post more code.

Winston
 
Bartender
Posts: 1166
17
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I can see that all your threads are related but I can't with any certainty really see how. My current understanding is that you have a set of files (the object files) that contain key words that need to be replaced by another word/value. The replacement values seem to be defined in another set of files ( the key definition files). I don't see how this relates to the title of this thread but ...

It seems to me that you need to read the replacement word/values for the files and build a (old value, new value) map. You then need to read ( a line at a time ) each of the files containing the targets to be replaced and then for each line read replace all the words in these lines if they match the key words in the map.

If this is the case then you seem to need to -

a) generate the (old value, new value) map from the key definition files.
b) for each file the object file set
define a file to write the result into,
read each line of the object file,
for each line replace all words that have matching entries in the map
write the modified line to the result file.

I can think of many many ways to implement the replacement part but much depends on how many key values there are.



 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, What i am understanding regarding your question,

Compare two files content. If the content is matching, then create 'new file' and write the matched content into the 'new file'. Is my understanding correct ?

If it is correct ,

Read the content from 'first file' and stored into one list or array or something object.
Read the content from 'second file' and stored into another one list or array or map or any object

Then compare two object content one by one, if it matches then stored that matched word into another result object.
Put the 'result object' into 'new file'.

This is basic logic for two files, similarly you can applied multiple files in single directory.
 
reply
    Bookmark Topic Watch Topic
  • New Topic