私はJavaの初心者で、これをEclipseで動作させようとしています。ただし、 にreadLine
取り消し線が引かれ、非推奨であるという通知が表示されます。少しではありませんが、コードは機能しwhile ((var2 = var5.readLine()) != null) {
ます...だから、それを修正する方法を考えています。
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");
}
}
}