-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
71 lines (60 loc) · 2.07 KB
/
Main.java
File metadata and controls
71 lines (60 loc) · 2.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package BufferReader;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
import javax.xml.soap.SAAJResult;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
// try(FileWriter writer = new FileWriter("src/FileReaderBufferReaderBufferWriter/students.txt")){
// int i=1;
// String student;
// while(true) {
//
// Scanner scanner = new Scanner(System.in);
// System.out.print("Bir Ogrenci Giriniz:");
// student = scanner.nextLine();
// if(student.equals("-1")) {
// break;
// }
// writer.write(i + ".ogrenci : "+ student + "\n");
// i++;
// }
// } catch (IOException e) {
// // TODO Auto-generated catch block
// System.out.println("Dosya acilirken bir hata oldu.");
// }
//Okuma bolumu
//Bir karakter okuyup geri geliyor bu sebeble BufferReader(Kume olusturuyor dosyadaki \n gorene kadar hepsini kumeye koyuyor.)
//daha iyi cunku hardiske gidip gelmiyoruz bu sebeple.
//try(Scanner scanner = new Scanner(new BufferedReader(new FileReader("src/BufferReader/students.txt")))){
//
//
// while(scanner.hasNextLine()) {
//
// String ogrenci_bilgisi = scanner.nextLine();
// String[] array =ogrenci_bilgisi.split(",");
// if(array[1].equals("Computer Science")) {
// System.out.println("Ogrenci Bilgisi:" + ogrenci_bilgisi);
// }
// }
// } catch (FileNotFoundException e) {
// // TODO Auto-generated catch block
// System.out.println("Dosya Bulunamadi...");
// } catch (IOException e) {
// // TODO Auto-generated catch block
// System.out.println("Dosya acilirken bir hata oldu.");
// }
//BufferedWriter
try(BufferedWriter writer = new BufferedWriter(new FileWriter("src/BufferReader/students.txt",true))){
writer.write("Ali Ozan,Insaat Muhendisligi\n");
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("Dosya acma sirasinda bir problem oldu..");
}
}
}