반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- tensorflow
- 데이터전문기관
- cudnn
- bccard
- 결합전문기관
- classification
- 대이터
- paragraph
- 재귀함수
- mglearn
- Keras
- CES 2O21 참여
- postorder
- pycharm
- 머신러닝
- html
- C언어
- vscode
- java역사
- 웹 용어
- web
- 자료구조
- broscoding
- CES 2O21 참가
- web 사진
- KNeighborsClassifier
- inorder
- web 개발
- discrete_scatter
- web 용어
Archives
- Today
- Total
bro's coding
java.byte파일 컨트롤 본문
반응형
package step4;
import java.io.IOException;
// byte stream을 이용해 이미지 입출력
// FileInputStream < BufferedInputStream
// FileOutputStream < BufferedOuptupStream
public class TestImageService {
public static void main(String[] args) {
String copyImagePath = "C:\\4. kosta215\\iotest4\\iu.jpeg";
String pasteImagePath = "C:\\4. kosta215\\iotest5\\복사본-iu.jpeg";
ImageService service = new ImageService(copyImagePath,pasteImagePath);
try {
service.copyAndPasteImage();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
package step4;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class ImageService {
private String copyImagePath;
private String pasteImagePath;
public ImageService(String copyImagePath, String pasteImagePath) {
super();
new File(pasteImagePath).getParentFile().mkdirs();
this.copyImagePath = copyImagePath;
this.pasteImagePath = pasteImagePath;
}
// 이밎 처리를 위해 ByteStream을 사용
// 입력 노드스트림 : FileInputStream, 입력 프로세스스트림 : BufferedInputStream
// 출력 노드스트림 : FileOutputStream, 출력 프로세스스트림 : BufferedOutputStream
public void copyAndPasteImage() throws IOException {
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
bis = new BufferedInputStream(new FileInputStream(copyImagePath));
bos = new BufferedOutputStream(new FileOutputStream(pasteImagePath));
int data = bis.read();
while (data != -1) {
bos.write(data);
data = bis.read();
}
} finally {
if (bis != null) {
bis.close();
}
if (bos != null) {
bis.close();
}
}
}
}
반응형
'[IT] > java' 카테고리의 다른 글
java.FileMove(파일 이동) (0) | 2021.03.16 |
---|---|
java.Object Serialization.transient(직렬화 제외) (0) | 2021.03.15 |
java.Object Serialization(객체 직렬화)/Object DeSerialization(객체 역직렬화) (0) | 2021.03.15 |
java.SerialVersionUID (0) | 2021.03.15 |
java.문자열 파일 컨트롤 (0) | 2021.03.15 |
java.file입력/출력 (0) | 2021.03.15 |
java.BufferedReader (0) | 2021.03.15 |
java.Scanner(입력) (0) | 2021.03.12 |
Comments