wood burning stoves*
The moose likes Beginning Java and the fly likes how to pass the value from one string to another using the directory ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to pass the value from one string to another using the directory ?" Watch "how to pass the value from one string to another using the directory ?" New topic
Author

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

deepika deepi
Ranch Hand

Joined: Jan 23, 2012
Posts: 199
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.
Winston Gutkowski
Bartender

Joined: Mar 17, 2011
Posts: 8427
    
  23

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Richard Tookey
Ranch Hand

Joined: Aug 27, 2012
Posts: 1110
    
  10

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.



Eswar Nec
Ranch Hand

Joined: May 02, 2010
Posts: 105
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.

Wake up! Don't let your smile be snatched away by anybody!
Regards, Eswar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to pass the value from one string to another using the directory ?