Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9221187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:31:24+00:00 2026-06-18T03:31:24+00:00

I know it’s reading the file because I have it print the contents of

  • 0

I know it’s reading the file because I have it print the contents of the txt file to the console but everytime I try .equals the variable doesn’t change to true/false just stays at true any ideas?

public static void readWebPage() {
      URLConnection connection;
      try {
       connection = new URL("https://dl.dropbox.com/u/40562795/List.txt").openConnection();
       @SuppressWarnings("resource")
       Scanner scanner = new Scanner(connection.getInputStream());
       scanner.useDelimiter("\\z");
       String text = scanner.next();
        System.out.println(text);
        if(text.equals("stop")){
            stop = true;
            System.out.println("Successfully stopped.");
        }else{ if(text.equals("-"))
            stop = false;
            System.out.println("Successfully started.");
        }
      } catch (MalformedURLException e) {
       e.printStackTrace();
      } catch (IOException e) {
       e.printStackTrace();
      }
 }

Edit:

That worked it’s able to read it now, but my variable isn’t updating to true/false. It stays at true or so this says in the console.

if(stop = false){
    System.out.println("stop = false.");
}else
if(stop = true){
    System.out.println("stop = true.");
}

How my variable is made:

 public static boolean stop = false;

That’s how I’ve made the variable and it should = false but stop nor – change it. I searched my java files for something that may be triggering it to true and couldn’t find anything.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:31:25+00:00Added an answer on June 18, 2026 at 3:31 am

    There is a trailing space after the - character in the remote text file. You could use a whitespace delimiter rather than a line terminator delimiter. Replace

    scanner.useDelimiter("\\z");
    

    with

    scanner.useDelimiter("\\s+");
    

    so that your text will match your .equals checks.

    Edit:

    From the edit, you have an assignment in your if statement expression:

    if (stop = false) {
    

    replace with

    if (stop == false) {
    

    or better

    if (!stop) {
    

    Overall this if statement is unnecessary, you can simply write

    System.out.println("stop = " + stop);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know it's the javascript causing the issue, but how I have no idea.
I know jquery have backwardscompatibility files. But if you link to this specific version:
I know questions like this have been asked before, but I'm not sure how
I know about this question , but I have the source and I'm having
know nothing about php, but I have this script that reads a folder and
I know I have done this before but I can't seem to remember where
I know I already have a similar post, but I can't for the life
Know this might be rather basic, but I been trying to figure out how
I know you can not set a key value dynamically, but what about the
I know that Phonegap has an event for back button, but it's only available

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.