URL.openstream() method can't read from link with &Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?Create ArrayList from arrayHow do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?Convert HTML + CSS to PDF with PHP?How to get the value from the GET parameters?Linking to an external URL in Javadoc?How can I open a URL in Android's web browser from my application?How to create an HTML button that acts like a link?Redirect from an HTML page

Is it possible to run Internet Explorer on OS X El Capitan?

Why is consensus so controversial in Britain?

Intersection point of 2 lines defined by 2 points each

What is a clear way to write a bar that has an extra beat?

RSA: Danger of using p to create q

Was any UN Security Council vote triple-vetoed?

Convert two switches to a dual stack, and add outlet - possible here?

Could an aircraft fly or hover using only jets of compressed air?

How much RAM could one put in a typical 80386 setup?

What does the "remote control" for a QF-4 look like?

What defenses are there against being summoned by the Gate spell?

Modeling an IP Address

Why is 150k or 200k jobs considered good when there's 300k+ births a month?

Is it possible to do 50 km distance without any previous training?

How is the claim "I am in New York only if I am in America" the same as "If I am in New York, then I am in America?

What's the output of a record needle playing an out-of-speed record

Do I have a twin with permutated remainders?

Which country benefited the most from UN Security Council vetoes?

I'm flying to France today and my passport expires in less than 2 months

tikz convert color string to hex value

Is it possible to record a short contained sound no longer than 60 milliseconds?

Replacing matching entries in one column of a file by another column from a different file

Approximately how much travel time was saved by the opening of the Suez Canal in 1869?

How does quantile regression compare to logistic regression with the variable split at the quantile?



URL.openstream() method can't read from link with &


Which “href” value should I use for JavaScript links, “#” or “javascript:void(0)”?Create ArrayList from arrayHow do I call one constructor from another in Java?How do I read / convert an InputStream into a String in Java?Convert HTML + CSS to PDF with PHP?How to get the value from the GET parameters?Linking to an external URL in Javadoc?How can I open a URL in Android's web browser from my application?How to create an HTML button that acts like a link?Redirect from an HTML page






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have a link to a .csv which looks like this:




http://website.com/data.csv?since=2019-03-21T00:00Z&sensor=xxx




My method get this link as URL



BufferedReader in = new BufferedReader(new InputStreamReader(URL.openStream()));


The problem is that it is not properly downloading .csv. I have realized that if I add 'amp;' after & it works properly. Is there any easy way to work this out?










share|improve this question




























    0















    I have a link to a .csv which looks like this:




    http://website.com/data.csv?since=2019-03-21T00:00Z&sensor=xxx




    My method get this link as URL



    BufferedReader in = new BufferedReader(new InputStreamReader(URL.openStream()));


    The problem is that it is not properly downloading .csv. I have realized that if I add 'amp;' after & it works properly. Is there any easy way to work this out?










    share|improve this question
























      0












      0








      0








      I have a link to a .csv which looks like this:




      http://website.com/data.csv?since=2019-03-21T00:00Z&sensor=xxx




      My method get this link as URL



      BufferedReader in = new BufferedReader(new InputStreamReader(URL.openStream()));


      The problem is that it is not properly downloading .csv. I have realized that if I add 'amp;' after & it works properly. Is there any easy way to work this out?










      share|improve this question














      I have a link to a .csv which looks like this:




      http://website.com/data.csv?since=2019-03-21T00:00Z&sensor=xxx




      My method get this link as URL



      BufferedReader in = new BufferedReader(new InputStreamReader(URL.openStream()));


      The problem is that it is not properly downloading .csv. I have realized that if I add 'amp;' after & it works properly. Is there any easy way to work this out?







      java html spring-boot url






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 21 at 23:03









      sebaokasebaoka

      478




      478






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I have found the solution: https://www.mkyong.com/java/java-httpurlconnection-follow-redirect-example/



          public URL getFinalUrl(URL url) 
          try
          HttpURLConnection conn = (HttpURLConnection) url.openConnection();
          conn.setReadTimeout(5000);
          conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
          conn.addRequestProperty("User-Agent", "Mozilla");
          conn.addRequestProperty("Referer", "google.com");

          boolean redirect = false;

          int status = conn.getResponseCode();
          if (status != HttpURLConnection.HTTP_OK)
          if (status == HttpURLConnection.HTTP_MOVED_TEMP

          String newUrl = null;
          if (redirect)
          // get redirect url from "location" header field
          newUrl = conn.getHeaderField("Location");

          // get the cookie if need, for login
          String cookies = conn.getHeaderField("Set-Cookie");

          // open the new connnection again
          conn = (HttpURLConnection) new URL(newUrl).openConnection();
          conn.setRequestProperty("Cookie", cookies);
          conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
          conn.addRequestProperty("User-Agent", "Mozilla");
          conn.addRequestProperty("Referer", "google.com");

          System.out.println(newUrl);
          return new URL(newUrl);
          catch (IOException ioe)
          System.out.println("Wrong sensor URL");

          return null;






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290511%2furl-openstream-method-cant-read-from-link-with%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            I have found the solution: https://www.mkyong.com/java/java-httpurlconnection-follow-redirect-example/



            public URL getFinalUrl(URL url) 
            try
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
            conn.setReadTimeout(5000);
            conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
            conn.addRequestProperty("User-Agent", "Mozilla");
            conn.addRequestProperty("Referer", "google.com");

            boolean redirect = false;

            int status = conn.getResponseCode();
            if (status != HttpURLConnection.HTTP_OK)
            if (status == HttpURLConnection.HTTP_MOVED_TEMP

            String newUrl = null;
            if (redirect)
            // get redirect url from "location" header field
            newUrl = conn.getHeaderField("Location");

            // get the cookie if need, for login
            String cookies = conn.getHeaderField("Set-Cookie");

            // open the new connnection again
            conn = (HttpURLConnection) new URL(newUrl).openConnection();
            conn.setRequestProperty("Cookie", cookies);
            conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
            conn.addRequestProperty("User-Agent", "Mozilla");
            conn.addRequestProperty("Referer", "google.com");

            System.out.println(newUrl);
            return new URL(newUrl);
            catch (IOException ioe)
            System.out.println("Wrong sensor URL");

            return null;






            share|improve this answer



























              0














              I have found the solution: https://www.mkyong.com/java/java-httpurlconnection-follow-redirect-example/



              public URL getFinalUrl(URL url) 
              try
              HttpURLConnection conn = (HttpURLConnection) url.openConnection();
              conn.setReadTimeout(5000);
              conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
              conn.addRequestProperty("User-Agent", "Mozilla");
              conn.addRequestProperty("Referer", "google.com");

              boolean redirect = false;

              int status = conn.getResponseCode();
              if (status != HttpURLConnection.HTTP_OK)
              if (status == HttpURLConnection.HTTP_MOVED_TEMP

              String newUrl = null;
              if (redirect)
              // get redirect url from "location" header field
              newUrl = conn.getHeaderField("Location");

              // get the cookie if need, for login
              String cookies = conn.getHeaderField("Set-Cookie");

              // open the new connnection again
              conn = (HttpURLConnection) new URL(newUrl).openConnection();
              conn.setRequestProperty("Cookie", cookies);
              conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
              conn.addRequestProperty("User-Agent", "Mozilla");
              conn.addRequestProperty("Referer", "google.com");

              System.out.println(newUrl);
              return new URL(newUrl);
              catch (IOException ioe)
              System.out.println("Wrong sensor URL");

              return null;






              share|improve this answer

























                0












                0








                0







                I have found the solution: https://www.mkyong.com/java/java-httpurlconnection-follow-redirect-example/



                public URL getFinalUrl(URL url) 
                try
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setReadTimeout(5000);
                conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
                conn.addRequestProperty("User-Agent", "Mozilla");
                conn.addRequestProperty("Referer", "google.com");

                boolean redirect = false;

                int status = conn.getResponseCode();
                if (status != HttpURLConnection.HTTP_OK)
                if (status == HttpURLConnection.HTTP_MOVED_TEMP

                String newUrl = null;
                if (redirect)
                // get redirect url from "location" header field
                newUrl = conn.getHeaderField("Location");

                // get the cookie if need, for login
                String cookies = conn.getHeaderField("Set-Cookie");

                // open the new connnection again
                conn = (HttpURLConnection) new URL(newUrl).openConnection();
                conn.setRequestProperty("Cookie", cookies);
                conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
                conn.addRequestProperty("User-Agent", "Mozilla");
                conn.addRequestProperty("Referer", "google.com");

                System.out.println(newUrl);
                return new URL(newUrl);
                catch (IOException ioe)
                System.out.println("Wrong sensor URL");

                return null;






                share|improve this answer













                I have found the solution: https://www.mkyong.com/java/java-httpurlconnection-follow-redirect-example/



                public URL getFinalUrl(URL url) 
                try
                HttpURLConnection conn = (HttpURLConnection) url.openConnection();
                conn.setReadTimeout(5000);
                conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
                conn.addRequestProperty("User-Agent", "Mozilla");
                conn.addRequestProperty("Referer", "google.com");

                boolean redirect = false;

                int status = conn.getResponseCode();
                if (status != HttpURLConnection.HTTP_OK)
                if (status == HttpURLConnection.HTTP_MOVED_TEMP

                String newUrl = null;
                if (redirect)
                // get redirect url from "location" header field
                newUrl = conn.getHeaderField("Location");

                // get the cookie if need, for login
                String cookies = conn.getHeaderField("Set-Cookie");

                // open the new connnection again
                conn = (HttpURLConnection) new URL(newUrl).openConnection();
                conn.setRequestProperty("Cookie", cookies);
                conn.addRequestProperty("Accept-Language", "en-US,en;q=0.8");
                conn.addRequestProperty("User-Agent", "Mozilla");
                conn.addRequestProperty("Referer", "google.com");

                System.out.println(newUrl);
                return new URL(newUrl);
                catch (IOException ioe)
                System.out.println("Wrong sensor URL");

                return null;







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 21 at 23:54









                sebaokasebaoka

                478




                478





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55290511%2furl-openstream-method-cant-read-from-link-with%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript