Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read SiteMap

Tags: , , , , ,

Sponsored Links



Method does not receive parameter

Software Development


Reply
 
Thread Tools Search this Thread
  #1  
Old 11-03-2010
Member
 
Join Date: Mar 2010
Posts: 192
Method does not receive parameter

Hello,
I have applied this logic, if i is greater than -1, a method is called and I gave him an argument on File, the BufferedReader and FileReader. Strangely, when I pass the arguments, the method does not give me the desired result, i.e the method does not read lines from txt file in while loop. I do not have any idea of what is going on. If you know how to fix the problem then please help me with this. Thanks in advance.
__________________
www.techarena.in
Reply With Quote
  #2  
Old 11-03-2010
Member
 
Join Date: Nov 2009
Posts: 583
Re: Method does not receive parameter

Hello,
I think this is the mistake that you could have made in your code.
Code:
while ((line = br.readLine())!=null)
In other words, when you stop the line returned is null. Then in your second method, you begin to read from the same place, in short, there's nothing to read, so you can spend forever in your second loop. By creating a new BufferedReader (method without argument), then place it at the beginning of lines, I think this should work very well.
Reply With Quote
  #3  
Old 11-03-2010
Member
 
Join Date: Mar 2010
Posts: 192
Re: Method does not receive parameter

Hello,
This is my updated code and here it is, if you find any problem in the code then please guide me with the correct
Code:
Public class bg
{
 Public static void hand (String [] args) throws IOException
 {
  File fl = new File("c:\\bidon.txt ");
  FileReader flrd = new FileReader(fl);
  BufferedReader buff = new BufferedReader(en);
  
  String aRechercher = "SET PATH";
  String ln = "";
  int i =-1;
  
  while ((ln = buff.readLine())!=null)
  {
   System.out.System.out.println(row);
   
   if(row.indexOf(aRechercher)!=-1)
   {
    / / System.out.println ( "ligne.indexOf (aRechercher is" + ligne.indexOf (aRechercher));
    System.out.System.out.println("found!");
    i + +;
    System.out.System.out.println("i is" + I);
   }
  }
  
  }
 
 Public static void testmet(File fl, en FileReader, BufferedReader buff)throws IOException
 {
  File fl2 = new File("c:\\bidon2.txt ");
  FileWriter flwri = new FileWriter(fl2);
  BufferedWriter buffwri = new BufferedWriter(flwri);
  String aRechercher = "SET PATH";
  
  String ln = "";
  int i =0;
  while ((ln = buff.readLine())!=null)
  {
   System.out.System.out.println("ln is"+ online);
   i + +;
   if (row.indexOf(aRechercher)!=-1)
   {
    ln + = "bogus";;
    buffwri.write(row);
    buffwri.newLine();
   }
   else
   {
    buffwri.write(row);
    buffwri.newLine();
   }
  }
  System.out.System.out.println("i is" + I);
  buffwri.close();
  
 }
}
__________________
www.techarena.in
Reply With Quote
  #4  
Old 11-03-2010
Member
 
Join Date: Dec 2009
Posts: 192
Re: Method does not receive parameter

Hello,
Even i had a similar kind of a problem in my code. What you say makes sense. I thought the cursor back to the beginning. There's there a way around it anyway to be able to send the file method, the BufferedReader and FileReader? Thanks for the valuable suggestion and also if you have any other alternative that can replace this method then please give let me know, I am interested in it. Thanks in advance.
Reply With Quote
  #5  
Old 11-03-2010
Member
 
Join Date: Nov 2009
Posts: 520
Re: Method does not receive parameter

Hello,
You can try something like this
Code:
private static void newMethode() throws IOException {
				File fl = new File("c:\\bidon.txt ");
FileReader flrd = new FileReader(fl);
BufferedReader buff = new BufferedReader(en);
 
		/ / Value to find
		String aRechercher = "SET PATH";
 
		/ / Treatment
		String ln = "";
StringBuffer strbuff = new StringBuffer();
		boolean isPresent = false;
 
		/ / For each row ...
		while ((ln = buff.readLine()) != null) {
			/ / Add the ln
			strbuff.append(row);
			/ / We check that the text is present in the ln ...
			if (row.indexOf(aRechercher) != -1) {
				/ / We found a ln that contains the lookup value, it
				/ / Add CAN
				isPresent = true;
strbuff.append(bogus);
			}
			/ / Add the newline
			strbuff.append('\ n');
		}
 
		/ / ... we write a new file if the text was present
		if (isPresent) {
			File fl2 = new File("c:\\bidon3.txt ");
FileWriter flwri = new FileWriter(fl2);
BufferedWriter bw = new BufferedWriter(flwri);
bw.write(strbuff.function toString() {
    [native code]
}());
bw.close();
flwri.close();
		}
	}
Reply With Quote
  #6  
Old 11-03-2010
Member
 
Join Date: Mar 2010
Posts: 192
Re: Method does not receive parameter

Hello,
Thanks for the code, if helped me a lot. I just wanted to go after the explanation, but having reopened the File with no problem.
I see in your code:
Code:
StringBuffer strbuff= new StringBuffer();
I have never used this buffer, it puts a line in the buffer I presume? Can you please explain me this. Thanks in advance.
__________________
www.techarena.in
Reply With Quote
Reply

  TechArena Community > Software > Software Development


Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Method does not receive parameter"
Thread Thread Starter Forum Replies Last Post
Passing object as a parameter in a method Karumbu Software Development 4 06-01-2011 01:07 AM
Method overriding versus method hiding in C# ^MALARVIZHI^ Software Development 4 25-12-2010 06:25 AM
Troubleshooting error messages that receive while trying to send and receive mail in Outlook hatred Windows Software 5 20-03-2010 06:44 AM
Is it possible to call destroy() method within init() Method? Level8 Software Development 3 10-12-2009 08:36 AM
What is method overriding and method overloading in java beelow Software Development 3 17-11-2009 08:20 AM


All times are GMT +5.5. The time now is 03:52 AM.