독해 테스트

1950s critics separated themselves from the masses by rejecting the ‘natural’ enjoyment afforded by products of mass culture through judgments based on a refined sense of realism. For example, in most critics championing Douglas Sirk’s films’ social critique, self-reflexivity, and, in particular, distancing effects, there is still a refusal of the ‘vulgar’ enjoyments suspected of soap operas. This refusal again functions to divorce the critic from an image of a mindless, pleasure-seeking crowd he or she has actually manufactured in order to definitively secure the righteous logic of ‘good’ taste. It also pushes negative notions of female taste and subjectivity. Critiques of mass culture seem always to bring to mind a disrespectful image of the feminine to represent the depths of the corruption of the people. The process of taste-making operated, then, to create hierarchical differences between the aesthete and the masses through the construction of aesthetic positions contrary to the perceived tasteless pleasures of the crowd.

 

URL 객체 사용

import java.net.*;
import java.io.*;
import static java.lang.System.out;

class URLTest1
{
	public static void main(String[] args) 
	{
		try{
		URL url=new URL(args[0]);
		// 명령줄 인수로 완전한 형태 - http://www.naver.com
		// ftp://ftp.kaist.ac.kr/pub/
		// http://www.kbs.co.kr
		// file:///c:\myjava\test.html
		out.println("Protocol:" +url.getProtocol());
		out.println("Host :" +url.getHost());
		out.println("Port :" +url.getPort());
		out.println("File :" +url.getFile());
		//포트가 -1을 반환하는 경우가 있는데, 이것은 -1번으로 url접속을 시도하는 것이 아니라
		//프로토콜에 해당하는 디폴트 포트로 접속이 일어난다는 점을 의미
		InputStream is = url.openStream();
		//openStream()메소드를 이용하면 URL이 위치한 곳과 자동으로 접속이 일어나고,
		// 결과로 InputStream이 반환된다.
		BufferedReader br = new BufferedReader(new InputStreamReader(is));
		String contents="";
		while((contents=br.readLine()) !=null) {
			out.println(contents);
		}
		br.close();
		is.close();

		}catch(Exception e) {
			e.printStackTrace();
		}
	}//main()---------
}//////////////////////////////////////////////////////////////////
import java.net.*;
import java.io.*;
//이미지 파일을 읽어 파일로 저장.

class  URLTest2
{
	public static void main(String[] args) throws MalformedURLException, IOException
	{
		String urlStr="http://s~~~90151.jpg";
		URL url = new URL(urlStr);
		// 스트림 얻어서 파일로 저장하자. myimg.jpg
		InputStream is = url.openStream();
		BufferedInputStream bis = new BufferedInputStream(is);
		FileOutputStream fos = new FileOutputStream("myimg.jpg");
		byte ba[] = new byte[1024];
		int n = 0;
		int count=0;
		URLConnection uc=url.openConnection();
		int fileSize=uc.getContentLength();
		System.out.println("파일크기:"+fileSize);
		System.out.println("컨텐트 타입: "+uc.getContentType());

		while((n=bis.read(ba)) !=-1) {
			fos.write(ba,0,n);
			count += n;
			fos.flush();
			System.out.print(((count*100) /fileSize)+"%");
		}
		fos.close();
		bis.close();
		is.close();

	}
}////////////////////////////////////////////////////////


'Java > Network' 카테고리의 다른 글

InetAddress 클래스 사용  (0) 2011.12.15

InetAddress 클래스 사용

import java.net.*;
class InetAddressTest
//InetAddress 클래스 사용 : ip를 추상화한 클래스

{
	public static void main(String[] args) 
	{
		try{
			InetAddress inet=null;
			inet=InetAddress.getByName(args[0]);
			// NetworkInterface mac;
			System.out.println("연결 됐습니다.");
			System.out.println("getHostName: "+inet.getHostName());
			System.out.println("getHostAddress:" +inet.getHostAddress());
			System.out.println("getLocalHost :" +inet.getLocalHost());
			// System.out.println("Mac Address :" +mac.getHardwareAddress());
			InetAddress[] inet2 = InetAddress.getAllByName("www.hanmail.net");
			for (int i=0; i < inet2.length ;i++ )
			{
				System.out.println(inet2[i]);
			}
		}catch(Exception e) {
			e.printStackTrace();
		}
	}//mail()----
}////////////////////////////////

'Java > Network' 카테고리의 다른 글

URL 객체 사용  (0) 2011.12.15

io와 swing활용 : 디렉토리목록 가져오기

import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
public class  MyDirDemo extends JFrame
implements ActionListener, ListSelectionListener
{
	JTextField tfDir;
	JList lst;
	File fileList[];//디렉토리의 파일 목록을 가질 변수
	JTextArea ta;
	JButton btSave, btClear, btColor;
	JComboBox combo;
	String [] fonts;

	BufferedReader br;
	BufferedWriter bw;

	public MyDirDemo(){
		super(":: MyDirDemo ::");
		Container cp=getContentPane();
		tfDir=new JTextField();
		cp.add(tfDir,"North");
		tfDir.setBorder(new TitledBorder("디렉토리명을 입력하세요"));

		lst=new JList();//디렉토리 파일 목록을 여기에 보여주자.
		cp.add(new JScrollPane(lst),"West");
		lst.setBorder(new TitledBorder("파일 목록"));

		//ta부착
		ta=new JTextArea();
		cp.add(new JScrollPane(ta),"Center");

		//아래(South)에 패널 부착
		JPanel p1=new JPanel();
		cp.add(p1,"South");
		p1.add(btSave=new JButton("SAVE"));
		p1.add(btClear=new JButton("CLEAR"));
		p1.add(btColor=new JButton("COLOR"));
		//시스템 서체를 가져오는 사용자 정의 메소드 호출
		fonts=getSystemFonts();
		combo=new JComboBox(fonts);
		p1.add(new JScrollPane(combo));

		//리스너 부착----
		tfDir.addActionListener(this);
		btSave.addActionListener(this);
		btClear.addActionListener(this);
		btColor.addActionListener(this);
		//JList에는 어떤 리스너 부착??
		lst.addListSelectionListener(this);


		addWindowListener(new WindowAdapter(){ 
			public void windowClosing(WindowEvent e){
				System.exit(0);
			}
		});
	}//생성자-------

	public void valueChanged(ListSelectionEvent e){
		Object o=e.getSource();
		if(o==lst){
			//1. 리스트에서 선택한 파일명을 얻어오자.
			//Object getSelectedValue()
			//boolean getValueIsAdjusting() 
			boolean res=e.getValueIsAdjusting();
			System.out.println("res: "+res);
			//마우스 클릭할 때true, 마우스 뗄때 false를 리턴.
			if(!res){		
				try{
					readFile();//사용자 정의 메소드 호출..
				}catch(IOException ex){
					JOptionPane.showMessageDialog(this,
						"Error: "+ex.getMessage());
				}
			}//if----------
		}
	}//--------------
	public String[] getSystemFonts(){
			GraphicsEnvironment ge=
				  GraphicsEnvironment.getLocalGraphicsEnvironment();
					String[] f=ge.getAvailableFontFamilyNames();
					return f;
	}//-----------------
	public void readFile() throws IOException{
		ta.setText("");//읽기전에 ta를 빈문자열로 초기화...
		Object obj=lst.getSelectedValue();
		
			//setTitle(obj.toString());
			File selFile=(File)obj;
	if(selFile !=null){
			System.out.println(selFile);
			//2. 그 파일이 java 또는  txt파일이라면
			String fname=selFile.getName();
			if(fname.endsWith(".java")||fname.endsWith(".txt")){
			//3. 1번 파일의 절대경로를 구한뒤
				String path=obj.toString();
			//4. 파일을 읽는 노드스트림과 연결한다.
				FileReader fr=new FileReader(selFile);
			//5. BufferedReader로 필터링...
			br=new BufferedReader(fr);
			//6. 반복문 돌면서 줄단위로 읽어온 내용을
			//7. ta에 append()하자.	
			String line="";
			while((line=br.readLine())!=null){
				ta.append(line+"\n");
			}//while----
			//8. 자원 반납
			if(br!=null) br.close();
			if(fr!=null) fr.close();

			}else{
				JOptionPane.showMessageDialog(this,
							"선택한 파일이 디렉토리이거나 읽기 힘든 파일입니다");
			}
	  }//if---널체크 if문---
	}//readFile()--------------

	public void actionPerformed(ActionEvent e){
		Object o=e.getSource();
		if(o==tfDir){
			//1. 사용자가 입력한 디렉토리명을 얻어온다.
			String dirName=tfDir.getText().trim();
			//2. 1에서 얻어온 문자열을 넣은 File객체 생성
			File dir=new File(dirName);
			//3. 디렉토리인지 아닌지 판별...
			if(dir.isDirectory()){
			//4. 디렉토리라면...해당 디렉토리의 파일 목록을 얻어오자.
				fileList=dir.listFiles();
				//String[] flist=dir.list();
				//File[] flist=dir.listFiles();
			}//if------
			//5. 얻어온 파일 목록을 JList에 붙이자...
			lst.setListData(fileList);
		}else if(o==btSave){
			saveFile();///사용자 정의 메소드 호출
		}else if(o==btClear){
			ta.setText("");
		}else if(o==btColor){
			changeTxtColor();//사용자 정의 메소드 호출
		}
	}//---------------
	public void changeTxtColor(){
		//1. JColorChooser객체의 메소드(showXXX())를 호출하여
		//   색상 다이얼로그를 띄운다.
		//static Color showDialog(Component component, String title, Color initialColor) 
		Color cr=JColorChooser.showDialog(this, "", Color.blue);
	
		//2. 사용자가 선택한 색상을 얻어온다.
		//3. ta에 그 색상을 글자색으로 적용한다.
		ta.setForeground(cr);

	}//changeTxtColor()--------
	public void saveFile(){
		//1. JFileChooser 객체를 생성하여 저장다이얼로그를 보여준다.
			JFileChooser jc=new JFileChooser();
			jc.showSaveDialog(this);
			//2. 1에서 사용자가 입력한 파일명을 얻어와
			// File getSelectedFile()  
			File saveFile=jc.getSelectedFile();
			//취소를 누르면 null 을 리턴함...따라서 널체크 필수..
			if(saveFile!=null)
				setTitle(saveFile.getName());
		try{
			String contents=ta.getText();
			if(contents==null|| contents.trim().equals("")){
				JOptionPane.showMessageDialog(this,"저장할 내용을"
													+"입력해야 합니다.");
				ta.requestFocus();
				//ta에 포커스 주기..
				return;
			}//if--
			//3. 파일에 쓰는 스트림과 노드 연결을 하고...
			FileWriter fw=new FileWriter(saveFile);
			//4. BufferedWriter로 필터링을 한 뒤		
			bw=new BufferedWriter(fw);
			//5. ta(텍스트에리어)의 내용을 4번 스트림을 통해
			//   파일에 쓰기 작업을 한다. 
			
			bw.write(contents);
			bw.flush();
			//6. 연결된 스트림 닫기.
			if(bw!=null) bw.close();
			if(fw!=null) fw.close();
		}catch(IOException ex){
			System.out.println("IO Error: "+ex.getMessage());
		}

	}//saveFile()---------

	public static void main(String[] args) 
	{
		MyDirDemo d=new MyDirDemo();
		d.setSize(800,500);
		d.setVisible(true);
	}
}

'Java > I_O' 카테고리의 다른 글

io와 swing 활용 : 이미지파일 카피  (0) 2011.12.11
Random Access File  (0) 2011.12.11
Object Input Output Stream  (0) 2011.12.11
Print Writer  (0) 2011.12.11
스트림 분류  (0) 2011.12.11

io와 swing 활용 : 이미지파일 카피

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import java.io.*;

public class  JTextFieldDemo extends JFrame implements ActionListener
{
	JTextField tf1, tf2;
	JButton bt;
	JLabel res;
	JProgressBar pb;
	JPasswordField pwd;
	

	public JTextFieldDemo() {
		super(":::JTextFieldDemo:::");
		makeGui();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}//생성자----------
	public void makeGui() {
		Container cp=getContentPane();
		cp.setLayout(new GridLayout(0,1));//행은 가변적, 열은 1열로 고정
		tf1=new JTextField();
		tf2=new JTextField();
		cp.add(tf1);
		cp.add(tf2);
		//프로그래스바 생성 및 부착
		pb=new JProgressBar();
		cp.add(pb);
		pb.setStringPainted(true);
		bt=new JButton("COPY", new ImageIcon("./img/img06.gif"));
		cp.add(bt);
		ImageIcon ic=new ImageIcon("./img/img05.gif");
		res=new JLabel("결과",ic,JLabel.CENTER);
		JScrollPane sp=new JScrollPane(res);//라벨에 스크롤바를 붙인다
		cp.add(sp);
		tf1.setBorder(new TitledBorder("원본파일(이미지파일)"));
		tf2.setBorder(new TitledBorder("목적파일"));

		bt.addActionListener(this);

	}//----------
	public void actionPerformed(ActionEvent e)  {
		Object o=e.getSource();
		if(o==bt) {
			//fileCopy();
			Thread tr=new MyThread();
			tr.start();
		}
	}//----------
	class MyThread extends Thread
	{
		public void run() {
			fileCopy();
		}
	}/////////////////
	public void fileCopy()  {
		FileInputStream fis=null;
		FileOutputStream fos=null;
		BufferedInputStream bis=null;
		BufferedOutputStream bos=null;
		
		//./img/img01.gif를 ./img/target.gif로 복사해 보자
		try
		{
			String source=tf1.getText().trim();
			String target=tf2.getText().trim();
			File sourceFile=new File(source);
			File targetFile=new File(target);
			//스트림 연결해서 읽고 쓰고 하자.
			fis =new FileInputStream(sourceFile);
			bis =new BufferedInputStream(fis);
			fos =new FileOutputStream(targetFile);
			bos =new BufferedOutputStream(fos);
			int n=0;
			int count=0;
			long filesize=sourceFile.length();//파일크기
			byte ba[]=new byte[1024];  //배열에 담아서 읽어들임
			while ((n=bis.read(ba)) != -1) 
			{
				count +=n;//읽은 바이트수, 프로그래스바에 설정
				//int per=(읽은바이트수/전체파일크기)*100
				pb.setValue(count);
				long per=(count*100/filesize);
				pb.setString ((int)(pb.getPercentComplete()*100)+" % 진행");
				
				bos.write(ba,0,n);
				bos.flush();
				try	{
					Thread.sleep(100);//0.1초 슬립
				}
				catch (Exception e) {
					e.printStackTrace();
				}

			}//while---
			bis.close(); bos.close();
			fis.close(); fos.close();
			//라벨의 아이콘 변경 작업.....
			ImageIcon i=new ImageIcon(target);
			res.setIcon(i);

		}
		catch (IOException e)
		{
			JOptionPane.showMessageDialog(this,e.getMessage());
		}
	}//fileCopy()-------

	public static void main(String[] args) 
	{
		JTextFieldDemo jfc=new JTextFieldDemo();
		jfc.setSize(300,400);
		jfc.setVisible(true);
	}
}


'Java > I_O' 카테고리의 다른 글

io와 swing활용 : 디렉토리목록 가져오기  (0) 2011.12.12
Random Access File  (0) 2011.12.11
Object Input Output Stream  (0) 2011.12.11
Print Writer  (0) 2011.12.11
스트림 분류  (0) 2011.12.11

Random Access File

import java.io.*;
import static java.lang.System.out;
class  RandomAccessFileTest
{
	public static void main(String[] args) 
		throws IOException
	{
		RandomAccessFile ra=new RandomAccessFile(args[0],"rw");
		out.println("현재 포인터: "+ra.getFilePointer());
		out.println(ra.length()+"bytes");//파일 크기 출력
		out.println("읽은 값1: "+ra.read());
		out.println("현재 포인터2: "+ra.getFilePointer());
		out.println("읽은 값2: "+((char)ra.read()));
		out.println("현재 포인터3: "+ra.getFilePointer());
		ra.seek(5);//포인터 이동...5지점으로...
		out.println("읽은 값3: "+(char)ra.read());//F
		//지금 현재 포인터: 6
		//쓰기...
		out.println("현재 포인터4: "+ra.getFilePointer());
		ra.write('f');
		ra.write('g');

		ra.seek(2);
		ra.write('H');
		ra.seek(ra.length());//끝으로 이동...
		ra.writeUTF("The End~");
		out.println("총 바이트 수:  "+ra.length());
		ra.close();
	}
}//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
import java.io.*;

class  RandomAccessFileTest2
{
	public static void main(String[] args) 
		throws IOException
	{
		RandomAccessFile ra
			=new RandomAccessFile(args[0],"rw");

		for (int i=0;i
  

'Java > I_O' 카테고리의 다른 글

io와 swing활용 : 디렉토리목록 가져오기  (0) 2011.12.12
io와 swing 활용 : 이미지파일 카피  (0) 2011.12.11
Object Input Output Stream  (0) 2011.12.11
Print Writer  (0) 2011.12.11
스트림 분류  (0) 2011.12.11

Object Input Output Stream

import java.io.Serializable;
import static java.lang.System.out;
// ObjectInputStream / ObjectOutputStream 예제

public class  Employee implements Serializable  //객체를 저장하기위해 반드시 구현
{
	String name;
	int age;
	transient int salary;

	public Employee() {
	}
	public Employee(String n, int a, int s)  {
		name=n; age=a; salary=s;
	}
	public void print() {
		out.println("---------Record for" +name+"--------");
		out.println(" Name: "  +name);
		out.println(" Age: "  +age);
		out.println(" : "  +salary);
	}
}////////////////////////////////////////////////////////////////////
import java.io.*;
import java.awt.*;
import java.util.*;

// 기능 : 객체를 파일로 저장
class  SaveEmp
{
	public static void main(String[] args) throws IOException
	{
		Employee e1=new Employee("홍길동", 22, 3000);
		Employee e2=new Employee("임꺽정", 33, 4000);

		String fileName="obj.ser";
		FileOutputStream fos =new FileOutputStream(fileName);
		ObjectOutputStream oos = new ObjectOutputStream(fos);
		//DataOutput인터페이스를 구현하고 있는 스트림.
		oos.writeObject(e1);
		oos.writeObject(e2);
		oos.writeObject(new Date());
		Frame f=new Frame("오브젝트 스트림");
		oos.writeObject(f);
		oos.flush();
		oos.close();
		fos.close();
	}//main()-----------
}//////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
import java.io.*;
import java.awt.*;
import java.util.*;

// 기능 : 객체를 파일로 저장
class  ReadEmp
{
	public static void main(String[] args) throws Exception
	{
		FileInputStream fis=new FileInputStream("obj.ser");
		ObjectInputStream ois=new ObjectInputStream(fis);

		Object o1=ois.readObject();
		Employee e1=(Employee)o1;
		Employee e2=(Employee)ois.readObject();

		Date d=(Date)ois.readObject();
		Frame f=(Frame)ois.readObject();

		e1.print();
		e2.print();
		System.out.println("저장된 객체 시간:"+d.toString());
		System.out.println("현재 시간:"+new Date().toString());

		f.setSize(200,200);
		f.setVisible(true);

		fis.close();
		ois.close();
	}
}


'Java > I_O' 카테고리의 다른 글

io와 swing 활용 : 이미지파일 카피  (0) 2011.12.11
Random Access File  (0) 2011.12.11
Print Writer  (0) 2011.12.11
스트림 분류  (0) 2011.12.11
Buffered Reader Writer  (0) 2011.12.11

Print Writer

import java.io.*;
//- 데이터소스: 파일
//- 데이터목적지: 파일, 도스콘솔
//- Node Stream: FileReader/FileWriter/ System.out
//- Filter Stream: BufferedReader/BufferedWriter/PrintWriter
import java.io.*;
class  FileCopyAndConsoleOut
{
	public static void main(String[] args) throws IOException
	{
		String sourceFile=args[0];//명령줄인수 하나: 읽을 파일명
		String targetFile="target.txt";
		//파일과 노드 연결--
		FileReader fr=new FileReader(sourceFile);
		//파일을 읽는 스트림: 두바이트 단위로...
		FileWriter fw=new FileWriter(targetFile);
		//파일에 쓰는 스트림: 두바이트 단위로...

		//필터링-BufferedReader/BufferedWriter와 연결
		//버퍼에 모아서 읽고 버퍼에 모아서 쓰기 작업
		//기본버퍼: 512byte
		BufferedReader br=new BufferedReader(fr);
		BufferedWriter bw=new BufferedWriter(fw);

		/*PrintWriter pw=new PrintWriter(
						new OutputStreamWriter(System.out));*/
		PrintWriter pw=new PrintWriter(System.out, true);
		//도스 콘솔에 읽은 파일내용을 출력해보자.
		//생성자에 true값을 넣어주면 auto flushing이 지원된다.
		//줄바꿈을 지원하는 메소드가 있다.--> println()

		String line="";
		//파일에 줄번호 (1: xxx )를 붙여서 출력하자.
		//콘솔에는 줄번호를 붙이고...모두 대문자로 바뀌어서 출력
		int num=0;
		while((line=br.readLine())!=null){
			num++;
			///////////////////
			pw.println(num+": "+line.toUpperCase());//콘솔에 출력
			//////////////////
			bw.write(num+": "+line);//파일에 출력
			bw.newLine();
			bw.flush();
		}//-----------
		pw.println(targetFile+"을 열어보세요^^");
		br.close(); bw.close(); pw.close();
		fr.close(); fw.close();
		
		
	}//main()--------
}


'Java > I_O' 카테고리의 다른 글

Random Access File  (0) 2011.12.11
Object Input Output Stream  (0) 2011.12.11
스트림 분류  (0) 2011.12.11
Buffered Reader Writer  (0) 2011.12.11
FileReader, FileWriter  (0) 2011.12.10

스트림 분류


'Java > I_O' 카테고리의 다른 글

Object Input Output Stream  (0) 2011.12.11
Print Writer  (0) 2011.12.11
Buffered Reader Writer  (0) 2011.12.11
FileReader, FileWriter  (0) 2011.12.10
FileReader 클래스  (0) 2011.12.10

Buffered Reader Writer

import java.io.*;
/*
키보드 입력에 도스콘솔상에 출력
- Node Stream:  System.in/ System.out
- Bridge Stream: InputStreamReader / OuputStreamWriter
*/
class  StandardInOut
{
	public static void main(String[] args) throws IOException{
			InputStream is=System.in;
			PrintStream ps=System.out;
			InputStreamReader ir=new InputStreamReader(is);
			OutputStreamWriter ow=new OutputStreamWriter(ps);
			int data=0;
			while((data=ir.read())!=-1){	
				//System.out.print((char)data);
				ow.write(data);
				ow.flush();
			}//while----
			System.out.println("The End");
			ir.close(); ow.close();
			is.close(); ps.close();
		
	}//main()----------
}//////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////
import java.io.*;
/*
키보드 입력에 도스콘솔상에 출력
- Node Stream:  System.in/ System.out
- Bridge Stream: InputStreamReader / OuputStreamWriter
- Filter Stream: BufferedReader / BufferedWriter
*/
class  StandardInOut2
{
	public static void main(String[] args) throws IOException
	{
		InputStreamReader ir=new InputStreamReader(System.in);
		OutputStreamWriter ow=new OutputStreamWriter(System.out);
	//	BufferedReader br=new BufferedReader(System.in);//[x]
	//BufferedReader br=new BufferedReader(ir);
	BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

	//BufferedWriter bw=new BufferedWriter(System.out);//[x]
	//반드시 중간 다리 역할하는 스트림과 연결돼야 한다.
	//BufferedWriter bw=new BufferedWriter(ow);
	BufferedWriter bw
		=new BufferedWriter(new OutputStreamWriter(System.out));

	int data=0;
	while((data=br.read())!=-1){
		bw.write(data);
		bw.flush();
	}//while-------
	ir.close(); ow.close();
	br.close(); bw.close();
	System.out.println("Bye ~");
	}
}/////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////많이 쓰임...외울것/////////////////////////////////////////////////////////
import java.io.*;
/*
키보드 입력에 도스콘솔상에 출력
- Node Stream:  System.in/ System.out
- Bridge Stream: InputStreamReader / OuputStreamWriter
- Filter Stream: BufferedReader / BufferedWriter
- BufferedReader의 readLine()메소드를 이용해보자.
*/
class  StandardInOut3
{
	public static void main(String[] args) throws IOException{
		BufferedReader key=new BufferedReader(new InputStreamReader(System.in));
		BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));

		//줄(line)단위로 입력을 받아보자.
		String line="";                       //입력이 String이기 때문에
		while((line=key.readLine())!=null){  //-1로 체크하는것이 아니다..
			out.write(line);
			out.newLine();//줄바꿈 주기
			out.flush();
		}//while------
		key.close(); out.close();
	}
}



'Java > I_O' 카테고리의 다른 글

Print Writer  (0) 2011.12.11
스트림 분류  (0) 2011.12.11
FileReader, FileWriter  (0) 2011.12.10
FileReader 클래스  (0) 2011.12.10
File class(dir 출력)  (0) 2011.12.10
◀ PREV 1234···6 NEXT ▶