-
-
Save uncoded-ro/410a004a16bc73ceacdca5fc7bd989f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package ro.virtualcampus.read; | |
import java.io.*; | |
public class ReadToFile { | |
public static void main(String[] args) throws IOException { | |
BufferedReader fin = null; | |
PrintWriter fout = null; | |
try { | |
fin = new BufferedReader(new InputStreamReader(System.in)); | |
fout = new PrintWriter(new FileWriter("out.txt")); | |
String buffer; | |
while ((buffer = fin.readLine()).indexOf(".") != 0) { | |
fout.println(buffer); | |
} | |
} catch (FileNotFoundException e) { | |
e.printStackTrace(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} finally { | |
if (fin != null) | |
fin.close(); | |
if (fout != null) | |
fout.close(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment