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 8852345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T13:22:34+00:00 2026-06-14T13:22:34+00:00

I’m a Java beginner, trying to get this to work in Eclipse. However, the

  • 0

I’m a Java beginner, trying to get this to work in Eclipse. However, the readLine is struck through and a notice says it is deprecated. The code works, albeit not the while ((var2 = var5.readLine()) != null) { bit … So I’m wondering how to fix it.

final class ScreenShotHelper$1 implements Runnable
{
    public void run()
    {
        try
        {
            String var1 = ScreenShotHelper.access$000().getAbsolutePath();
            String var2 = "";
            HttpURLConnection var3 = null;
            DataOutputStream var4 = null;
            DataInputStream var5 = null;
            String var6 = "\r\n";
            String var7 = "--";
            String var8 = "*****";
            String var9 = "";
            int var10 = 1048576;
            String var11 = "";
            var9 = Minecraft.getMinecraft().thePlayer.username;
            String var12 = "http://localhost/screenupload/index.php?playername=" + var9;
            try
            {
                FileInputStream var13 = new FileInputStream(new File(var1));
                URL var14 = new URL(var12);
                var3 = (HttpURLConnection)var14.openConnection();
                var3.setDoInput(true);
                var3.setDoOutput(true);
                var3.setUseCaches(false);
                var3.setRequestMethod("POST");
                var3.setRequestProperty("Connection", "Keep-Alive");
                var3.setRequestProperty("Content-Type", "multipart/form-data;boundary=" + var8);
                var4 = new DataOutputStream(var3.getOutputStream());
                var4.writeBytes(var7 + var8 + var6);
                var4.writeBytes("Content-Disposition: form-data; name=\"file\";filename=\"" + var1 + "\"" + var6);
                var4.writeBytes(var6);
                int var15 = var13.available();
                int var16 = Math.min(var15, var10);
                byte[] var17 = new byte[var16];

                for (int var18 = var13.read(var17, 0, var16); var18 > 0; var18 = var13.read(var17, 0, var16))
                {
                    var4.write(var17, 0, var16);
                    var15 = var13.available();
                    var16 = Math.min(var15, var10);
                }
                var4.writeBytes(var6);
                var4.writeBytes(var7 + var8 + var7 + var6);
                System.out.println("File is written");
                var13.close();
                var4.flush();
                var4.close();
            }
            catch (MalformedURLException var20)
            {
                System.out.println("error1: " + var20.getMessage());
            }
            catch (IOException var21)
            {
                System.out.println("error2: " + var21.getMessage());
            }

            try
            {
                var5 = new DataInputStream(var3.getInputStream());

                while ((var2 = var5.readLine()) != null) {
                    System.out.println("Server Response " + var2);
                    ScreenShotHelper.mc.thePlayer.addChatMessage("\u00a7aSuccessfully uploaded screenshot!  Direct link:");
                    ScreenShotHelper.mc.thePlayer.addChatMessage("\u00a7a" + var2);
                }
                var5.close();
            }
            catch (IOException var19)
            {
                System.out.println("error3: " + var19.getMessage());
            }
        }
        catch (Exception var22)
        {
            var22.printStackTrace();
            ScreenShotHelper.mc.thePlayer.addChatMessage("\u00a74failed to save");
        }
    }
}
  • 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-14T13:22:35+00:00Added an answer on June 14, 2026 at 1:22 pm
    • Give your variables meaningful names.
    • Declare your variables in the smallest possible scope.
    • Don’t assign dummy values (like null or "") to variables.
    • Avoid side-effects in tests.
    • Use automatic resource management to cleanly ensure that streams are closed.
    • Determine and use the correct character encoding when converting bytes to characters.

    Here is an example of your code that applies these points:

    try (InputStream is = connection.getInputStream()) {
      BufferedReader lines = new BufferedReader(new InputStreamReader(is, "UTF-8"));
      while (true) {
        String line = lines.readLine();
        if (line == null)
          break;
        System.out.println("Server Response " + line);
        ...
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.