내가 문자열 URL 텍스트 파일에서 모든 텍스트를 읽기 위해 노력하고 있지만 내가 이러한 오류 데 :는 시도 캐치에서 문자열 값을 전달하는 데 도움이 필요
package com.example.imagedownloadsample;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Environment;
import android.support.v7.app.ActionBarActivity;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.image_download);
//
try {
URL url = new URL(
"https://www.dropbox.com/s/s70xckuxjh5sbtw/pop.txt");
// read text returned by server
BufferedReader in = new BufferedReader(new InputStreamReader(
url.openStream()));
String currentUrl;
while ((currentUrl = in.readLine()) != null) {
System.out.println(currentUrl);
}
in.close();
} catch (MalformedURLException e) {
System.out.println("Malformed URL: " + e.getMessage());
} catch (IOException e) {
System.out.println("I/O Error: " + e.getMessage());
}
//
Picasso.with(this).load(currentUrl).into(target);
}
private Target target = new Target() {
@Override
public void onBitmapLoaded(final Bitmap bitmap, Picasso.LoadedFrom from) {
new Thread(new Runnable() {
@Override
public void run() {
String fileName = currentUrl.substring(
currentUrl.lastIndexOf('/') + 1,
currentUrl.length());
String fname = "/image-" + fileName + ".jpg";
File file = new File(Environment
.getExternalStorageDirectory().getPath() + fname);
if (file.exists())
file.delete();
try {
file.createNewFile();
FileOutputStream ostream = new FileOutputStream(file);
bitmap.compress(CompressFormat.JPEG, 100, ostream);
ostream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
if (placeHolderDrawable != null) {
}
}
};
}
이 내 코드는
Description Resource Path Location Type
currentUrl cannot be resolved to a variable MainActivity.java /Copy of ImageDownloadSample/src/com/example/imagedownloadsample line 51 Java Problem
currentUrl cannot be resolved MainActivity.java /Copy of ImageDownloadSample/src/com/example/imagedownloadsample line 62 Java Problem
currentUrl cannot be resolved MainActivity.java /Copy of ImageDownloadSample/src/com/example/imagedownloadsample line 64 Java Problem
currentUrl cannot be resolved MainActivity.java /Copy of ImageDownloadSample/src/com/example/imagedownloadsample line 63 Java Problem
입니다
................................................. .................................................. .................................................. ................
어쩌면 라인 51, 62, 63, 64을보고 시작? – djv