ftp서버에 mp3파일을 넣어두었습니다.
클라이언트로는 피씨용 (vb.net) 과 안드로이드, 2가지로 개발하고 있습니다.
피씨용에서는 파일명에 한글이 있던 없던 에러가 발생하지 않습니다만, 안드로이드용에서는 한글이 포함된 경우에 한해서 에러가 발생합니다.
다음은 피씨용에서 다운로드가 성공했을 경우의 로그내용입니다.
... RETR [김광석]그루터기.mp3 ... /2_sound/취미/MusicPlayer/[김광석]그루터기.mp3 |
다음은 안드로이드용에서 다운로드가 실패했을 경우의 로그내용입니다. (한글부분에 화살표 및 ++만 있습니다.)
... RETR []++.mp3 ... /2_sound/[]++.mp3 |
다음은 한글포함시 에러가 발생한 안드로이드 소스코드입니다.
String clsSERVERIP = "112.171.53.59"; int clsPORT = 21; String clsSERVERID = "Anonymous"; String clsSERVERPW = ""; downloadAndSaveFile2(clsSERVERIP, clsPORT, clsSERVERID, clsSERVERPW, "[김광석]광야에서.mp3");
... private Boolean downloadAndSaveFile2(String argServer, int argPortNumber, String argUser, String argPassword, String argFilename) throws IOException { FTPClient localFtp = null; File localFile1; localFtp = new FTPClient(); localFtp.connect(argServer, argPortNumber); localFtp.login(argUser, argPassword); localFtp.setFileType(FTP.BINARY_FILE_TYPE); localFtp.enterLocalPassiveMode(); localFtp.setControlEncoding("euc-kr"); //#####1.1 쿼리를 통해 파일사이즈 받아오기 -- (생략) boolean localSuccess = false; CopyStreamAdapter streamListener = new CopyStreamAdapter() { @Override public void bytesTransferred(long totalBytesTransferred, int bytesTransferred, long streamSize) { if(totalBytesTransferred % 50000 == 0){ clsProgressValue = (int)(totalBytesTransferred*100/clsFileSize); Message localMainMsg = clsMainHandler.obtainMessage(); localMainMsg.what = 0; localMainMsg.arg1 = clsProgressValue; clsMainHandler.sendMessage(localMainMsg); }else if(totalBytesTransferred == clsFileSize){ clsProgressValue = (int)(totalBytesTransferred*100/clsFileSize); Message localMainMsg = clsMainHandler.obtainMessage(); localMainMsg.what = 0; localMainMsg.arg1 = clsProgressValue; clsMainHandler.sendMessage(localMainMsg); } } }; localFtp.setCopyStreamListener(streamListener);
String localDirPath = "/sdcard/ftpRoot/2_sound/취미/MusicPlayer"; File localDirectory = new File(localDirPath); if(!localDirectory.exists())localDirectory.mkdirs(); localFile1 = new File(localDirPath + File.separator + argFilename); if (localFile1.exists() && localFile1.length() == clsFileSize && clsFileSize != 0) { //프로그래스 (진행율) 업데이트 clsProgressValue = 100; Message localMainMsg = clsMainHandler.obtainMessage(); localMainMsg.what = 0; localMainMsg.arg1 = clsProgressValue; clsMainHandler.sendMessage(localMainMsg); localSuccess = true; }else{ OutputStream localOutputStream = null; try { localOutputStream = new BufferedOutputStream(new FileOutputStream(localFile1)); localSuccess = localFtp.retrieveFile(argFilename, localOutputStream); } catch (Exception e) { e.printStackTrace(); } finally { if (localOutputStream != null) { try { localOutputStream.close(); } catch (Exception e) {e.printStackTrace();} } } } localFtp.logout();localFtp.disconnect(); return localSuccess; } |
구글링을 할려 해도 '한글오류' 를 어떻게 key-in 해야할지 모르겠습니다.
도움부탁드립니다.