How to set else word not found when read text file? [on hold]












-1












$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();
}
}












share|improve this question







New contributor




NoobHere is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.







$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.





















    -1












    $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();
    }
    }












    share|improve this question







    New contributor




    NoobHere is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.







    $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.



















      -1












      -1








      -1





      $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();
      }
      }












      share|improve this question







      New contributor




      NoobHere is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.







      $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






      share|improve this question







      New contributor




      NoobHere is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      NoobHere is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      NoobHere is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 1 hour ago









      NoobHereNoobHere

      1




      1




      New contributor




      NoobHere is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      NoobHere is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      NoobHere is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.




      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.






















          0






          active

          oldest

          votes

















          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes

          Popular posts from this blog

          How to make a Squid Proxy server?

          Is this a new Fibonacci Identity?

          19世紀