|
| |||||||||
| Tags: arguments, class, function, method, object, receive parameter |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| 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 |
|
#2
| |||
| |||
| 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) |
|
#3
| |||
| |||
| 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 |
|
#4
| |||
| |||
| 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. |
|
#5
| |||
| |||
| 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();
}
} |
|
#6
| |||
| |||
| 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();
__________________ www.techarena.in |
![]() |
|
| Thread Tools | Search this Thread |
| |
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 |