package co.common.test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class testMain {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Object obSend = null;
String file = "C:/Users/KwonSang/Downloads/";
String Name = "sikumi.png";
FileInputStream fis = new FileInputStream(file+"/"+Name);
HashMap<String, String> ha = new HashMap<String,String>();
ha.put("ID","1");
ha.put("PASSWORD","pass");
ha.put("file",file);
ha.put("Name",Name);
StringBuffer sb = new StringBuffer();
//---------------------------------------------------
// Send Data => Object
//---------------------------------------------------
int data = 0;
while((data=fis.read())!=-1) {
sb.append(data+",");
}
ha.put("IMGDATA", sb.toString());
obSend = ha;
sb=null;
fis.close();
//sb.setLength(0);
//ha.clear();
//---------------------------------------------------
// Receiver Data(Object) => File
//---------------------------------------------------
HashMap<String, String> rha = (HashMap<String, String>)obSend;
String rid = rha.get("ID");
String rpassword = rha.get("PASSWORD");
String rfile = rha.get("file");
String rName = "copy_"+rha.get("Name");
FileOutputStream outputStream =
new FileOutputStream(new File(rfile+"/"+rName));
String[] array = rha.get("IMGDATA").split(",");
Integer[] intarray=new Integer[array.length];
int i=0;
for(String str:array){
intarray[i]=Integer.parseInt(str);//Exception in this line
i++;
}
for(int idata : intarray){
outputStream.write(idata);
}
outputStream.close();
}
}
'Language > Java' 카테고리의 다른 글
ubuntu jdk 설치 위치 (0) | 2016.06.23 |
---|---|
자바 extends, implement (0) | 2016.02.04 |
[JNI] JNI 형식 및 데이터 구조 (0) | 2016.02.04 |
Java 개발 환경 구축_1 (0) | 2016.02.04 |
#01.개발환경 구축하기! (JDK) (0) | 2016.02.04 |