0
URL에서 이미지 파일을 다운로드하고 싶습니다. 내 코드는 인터넷의 이미지에 대한 URL에 대해서는 정상적으로 작동하지만 Wi-Fi 핫스팟을 통해 내 Android 휴대 전화에 연결된 URL을 사용하여 내 PC에서 파일을 다운로드 할 수있는 방법을 찾을 수 없습니다. 이것은 가능한가? 그렇다면, 어떻게 말해주십시오.URL을 사용하여 Wifi 핫스팟을 통해 연결된 컴퓨터에서 파일 다운로드
`URL url = new URL("file://192.168.43.198/f:/ur/demo.jpg");
URLConnection conection = url.openConnection();
conection.connect();
// getting file length
int lenghtOfFile = conection.getContentLength();
// input stream to read file - with 8k buffer
InputStream input = new BufferedInputStream(url.openStream(), 8192);
// Output stream to write file
OutputStream output = new FileOutputStream("/sdcard/downloadedfile.jpg");
byte data[] = new byte[1024];
while ((count = input.read(data)) != -1) {
total += count;
// writing data to file
output.write(data, 0, count);
}
`
도움이 되나요? http://stackoverflow.com/questions/6561317/get-ip-from-wifi-hotspot-in-android – AndyFaizan
아니요! @AndyFaizan. ipconfig를 사용하여 PC의 IP 주소를 결정했습니다. 이 접근법은 소켓을 사용하는 다른 네트워크 프로그램에서도 잘 작동합니다. 그러나 이것으로는 아닙니다. – Shashank
확인. 이건 어때? http://stackoverflow.com/questions/9906021/getting-the-ip-address-of-client-or-getting-the-informationssid-of-clients-con – AndyFaizan