Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- public class IOStreams {
- public static boolean checkIfNumber(String line){
- if(Character.isDigit(line.charAt(0)))
- return true;
- else return false;
- }
- public static void main(String[] args) throws IOException {
- BufferedReader br=null;
- BufferedWriter bw=null;
- try {
- br = new BufferedReader(new InputStreamReader(new FileInputStream("izvor.txt")));
- bw = new BufferedWriter(new FileWriter("destinacija.txt"));
- String line = null;
- while (true) {
- line = br.readLine();
- if (line == null)
- break;
- if (checkIfNumber(line)) {
- bw.write(line + "\n");
- }
- }
- }finally {
- if(br!=null){
- br.close();
- }
- if(bw!=null){
- bw.flush();
- bw.close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement