0
안드로이드에서 내 PC와 클라이언트에 서버를 만들었습니다 ... 소켓과 클라이언트 안드로이드를 통해 JPG 파일을 읽고 성공적으로 읽었습니다. 하지만 그걸 SD 카드에 저장하고 싶습니다. 도와주세요 ...안드로이드 - 서버 소켓에서 sdcard로 파일을 저장하는 방법 pdf 및 jpg ...?
안드로이드에서 내 PC와 클라이언트에 서버를 만들었습니다 ... 소켓과 클라이언트 안드로이드를 통해 JPG 파일을 읽고 성공적으로 읽었습니다. 하지만 그걸 SD 카드에 저장하고 싶습니다. 도와주세요 ...안드로이드 - 서버 소켓에서 sdcard로 파일을 저장하는 방법 pdf 및 jpg ...?
private void copytoSD() throws IOException{
//Open your local file as the input stream
InputStream myInput = //your input Stream
// Path to the just created empty db
String outFileName = Environment.getExternalStorageDirectory().toString+"/filename.jpg";
//Open the empty db as the output stream
OutputStream myOutput = new FileOutputStream(outFileName);
//transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[2048];
int length;
while ((length = myInput.read(buffer))>0){
myOutput.write(buffer, 0, length);
}
//Close the streams
myOutput.flush();
myOutput.close();
myInput.close();
}