??????? ?????? ????? - Pattern Wrapper

Send Snippet To: Save this snippet to Code Collector Pro -- view all laletin's snippets
language: Java
license: Other

Code for Snippet:

                
public static void main(String[] args) throws IOException
{
 //?????? ?????? ? ??????
 StringBuilder sb = new StringBuilder();
 sb.append("Lena").append('\n');
 sb.append("Olya").append('\n');
 sb.append("Anya").append('\n');
 String data = sb.toString();
 
 //??????????? ?????? ? ????? ByteArrayInputStream
 InputStream is = new ByteArrayInputStream(data.getBytes());
 
 //????????? in
 System.setIn(is);
 
 //???????? ??????? ?????, ??????? ?? ??????????? ? ????? ????????????
 readAndPrintLine();
}
 
public static void readAndPrintLine() throws IOException
{
 InputStreamReader isr = new InputStreamReader(System.in);
 BufferedReader reader = new BufferedReader(isr);
 
 while (true)
 {
  String line = reader.readLine();
  if (line == null) break;
  System.out.println(line);
 }
 reader.close();
 isr.close();
}
comments powered by Disqus

Info

Link to this snippet:


Download to Code Collector

To use the direct link to your snippet on CodeCollector.net either copy the html from the above section or drag the Download to Code Collector to where you would like to use it.

More Info:

Times Viewed: 16
Date Added: 2017-06-21 07:27:12
Last Modified: 2017-08-19 15:16:01

Web Analytics