JAVA-Network-TCP
[TCP client]
import java.io.DataInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
//client
//server IP: 192.168.0.24
//port: 9999
public class Ex02_TCP_Client {
public static void main(String[] args) throws Exception, IOException {
Socket socket = new Socket("192.168.0.36", 9999);
System.out.prin...
JAVA-Network-URLConnection
[URLConnection]
import java.io.BufferedInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
//네트워크 작업을 할 수 있는 자원
//JAVA API 제공
//클래스를 통해서
//URL 클래스 (인터넷 상에 주소를 다루는 클래스)
//URLConnection 클래스(연결된 URL 주소로 부터 다양한 정보와 작업)
//http://image3.kangcom.com/2018/02/b_pic/201802028179.j...
JAVA-I/O-DOS
[DOS]
public class P01_IO_DOS_COPY {
public static void main(String[] args) {
if(args[1].equals("copy")) {
copy(args);
}
}
static void copy(String[] args) {
File original = new File(args[0] + "\\" + args[2]); //원본 파일명
File copy = new File(args[0] + "\\" + args[3]); //사본 디렉토리명/파일명
if(args.length != 4) {
System.out.printl...
JAVA-I/O-DataStream
[DataStream]
[DataOutPutStream]
public static void main(String[] args) {
int[] score = {100,60,55,94,12};
try {
FileOutputStream fos = new FileOutputStream("score.txt");
DataOutputStream dos = new DataOutputStream(fos);
for(int i = 0 ; i < score.length ;i++) {
dos.writeInt(score[i]); //정수값 write > read(DataInputStream)
...
JAVA-I/O-PrintWriter
[PrintWriter]
PrintWriter 클래스를 사용하면 [출력형식] 정의
public static void main(String[] args) {
try{
//출력전용 (파일 생성 기능)
PrintWriter pw = new PrintWriter("C:\\Temp\\homework.txt");
pw.println("**************************************");
pw.println("* HOMEWORK *");
pw.println("**************************************");
...
JAVA-I/O-File
[File]
File 클래스
파일(a.txt) 생성, 수정, 삭제
디렉토리(폴더) 생성, 삭제
주로 사용: 파일정보, 폴더정보
C#: File, Directory 클래스
절대경로: C:\, D:\, C:\Temp\a.txt
상대경로: 나를 중심으로
public static void main(String[] args) {
String path="C:\\Temp\\file.txt"; //기존에 만들어진 파일 정보만
File f = new File(path);
//f.createNewFile() //파일생성
String filename = f.getName();
System.out.println("파일명"...
JAVA-I/O-Buffer
[Buffer]
컴퓨터 느린 작업 (DISK 파일 read, write)
File 작업 (DISK) (read, write) byte 단위
위 같은 문제를 해결하기 위해서
Buffer 메모리 (작접 해 둔것을)
무조건: file 작업할때 중간에 Buffer 사용하기!!!
File I/O 성능개선
Line 단위 처리
JAVA API
보조 스트림(input, output 추상클래스 상속한 클래스가 객체로 존재해야지만 사용가능)
BufferedInputStream
BufferedOutputStream
public static void main(String[] args) {
FileOutputStream fos = ...
JAVA-I/O-Basic
I/O
1. stream (연결통로, 입출력통로, 중간매개체)
2. stream 입출력의 크기 (음료빨대: 기본적으로 1Byte) » Byte 입출력 » Byte[] 배열
3. JAVA API가 제공하는 클래스
Byte 처리
InputStream(추상), OutputStream(추상)
두 개의 추상클래스 상속 (재정의) 클래스는
대상(memory)
ByteArrayInputStream, ByteArrayOutputStream
대상(file)
FileInputStream, FileOutputStream
추가적으로 보조 클래스
Buffer (I/O) 성능향상
BufferedInputStream, Buffere...
전체 글 47개, 6 페이지