How to set else word not found when read text file? [on hold]
$begingroup$
My Text file will be as below :
a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|1
b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|2
c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|3
My plan is else if not found the output will focus on the function:-
"(!removeterm.equalsIgnoreCase(Ch1)"
Because when i run the program the output will be like this..
Data not Found !
Data not Found !
Data Found
How can i just skip to the point?
I want my output will be like this :-
Data Found !
This is my last edit code, and im stuck here..
public class test2function {
static String filepath = "test.txt";
static String Ch1 = "3";
public static void main(String args) throws IOException {
try (BufferedReader r = new BufferedReader(new FileReader(filepath))) {
String line;
while ((line = r.readLine()) != null) {
String element = line.split("\|");
String removeterm = element[24].trim();
if(removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data Found");
break;
}
else if(!removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data not Found");
break;
}
}
r.close();
}catch (IOException e1) {
e1.printStackTrace();
}
}
java eclipse
New contributor
$endgroup$
put on hold as off-topic by AJNeufeld, tinstaafl, Jamal♦ 38 mins ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, tinstaafl, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
My Text file will be as below :
a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|1
b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|2
c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|3
My plan is else if not found the output will focus on the function:-
"(!removeterm.equalsIgnoreCase(Ch1)"
Because when i run the program the output will be like this..
Data not Found !
Data not Found !
Data Found
How can i just skip to the point?
I want my output will be like this :-
Data Found !
This is my last edit code, and im stuck here..
public class test2function {
static String filepath = "test.txt";
static String Ch1 = "3";
public static void main(String args) throws IOException {
try (BufferedReader r = new BufferedReader(new FileReader(filepath))) {
String line;
while ((line = r.readLine()) != null) {
String element = line.split("\|");
String removeterm = element[24].trim();
if(removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data Found");
break;
}
else if(!removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data not Found");
break;
}
}
r.close();
}catch (IOException e1) {
e1.printStackTrace();
}
}
java eclipse
New contributor
$endgroup$
put on hold as off-topic by AJNeufeld, tinstaafl, Jamal♦ 38 mins ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, tinstaafl, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
$begingroup$
My Text file will be as below :
a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|1
b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|2
c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|3
My plan is else if not found the output will focus on the function:-
"(!removeterm.equalsIgnoreCase(Ch1)"
Because when i run the program the output will be like this..
Data not Found !
Data not Found !
Data Found
How can i just skip to the point?
I want my output will be like this :-
Data Found !
This is my last edit code, and im stuck here..
public class test2function {
static String filepath = "test.txt";
static String Ch1 = "3";
public static void main(String args) throws IOException {
try (BufferedReader r = new BufferedReader(new FileReader(filepath))) {
String line;
while ((line = r.readLine()) != null) {
String element = line.split("\|");
String removeterm = element[24].trim();
if(removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data Found");
break;
}
else if(!removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data not Found");
break;
}
}
r.close();
}catch (IOException e1) {
e1.printStackTrace();
}
}
java eclipse
New contributor
$endgroup$
My Text file will be as below :
a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|a|1
b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|b|2
c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|3
My plan is else if not found the output will focus on the function:-
"(!removeterm.equalsIgnoreCase(Ch1)"
Because when i run the program the output will be like this..
Data not Found !
Data not Found !
Data Found
How can i just skip to the point?
I want my output will be like this :-
Data Found !
This is my last edit code, and im stuck here..
public class test2function {
static String filepath = "test.txt";
static String Ch1 = "3";
public static void main(String args) throws IOException {
try (BufferedReader r = new BufferedReader(new FileReader(filepath))) {
String line;
while ((line = r.readLine()) != null) {
String element = line.split("\|");
String removeterm = element[24].trim();
if(removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data Found");
break;
}
else if(!removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data not Found");
break;
}
}
r.close();
}catch (IOException e1) {
e1.printStackTrace();
}
}
public class test2function {
static String filepath = "test.txt";
static String Ch1 = "3";
public static void main(String args) throws IOException {
try (BufferedReader r = new BufferedReader(new FileReader(filepath))) {
String line;
while ((line = r.readLine()) != null) {
String element = line.split("\|");
String removeterm = element[24].trim();
if(removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data Found");
break;
}
else if(!removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data not Found");
break;
}
}
r.close();
}catch (IOException e1) {
e1.printStackTrace();
}
}
public class test2function {
static String filepath = "test.txt";
static String Ch1 = "3";
public static void main(String args) throws IOException {
try (BufferedReader r = new BufferedReader(new FileReader(filepath))) {
String line;
while ((line = r.readLine()) != null) {
String element = line.split("\|");
String removeterm = element[24].trim();
if(removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data Found");
break;
}
else if(!removeterm.equalsIgnoreCase(Ch1)) {
System.out.println("Data not Found");
break;
}
}
r.close();
}catch (IOException e1) {
e1.printStackTrace();
}
}
java eclipse
java eclipse
New contributor
New contributor
New contributor
asked 1 hour ago
NoobHereNoobHere
1
1
New contributor
New contributor
put on hold as off-topic by AJNeufeld, tinstaafl, Jamal♦ 38 mins ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, tinstaafl, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
put on hold as off-topic by AJNeufeld, tinstaafl, Jamal♦ 38 mins ago
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Code not implemented or not working as intended: Code Review is a community where programmers peer-review your working code to address issues such as security, maintainability, performance, and scalability. We require that the code be working correctly, to the best of the author's knowledge, before proceeding with a review." – AJNeufeld, tinstaafl, Jamal
If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
0
active
oldest
votes
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes