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

                    SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                    은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현