Created
February 19, 2022 20:00
-
-
Save argestes/c4484750e8f3d7cb1b2c11d345ee5399 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 com.birohcek; | |
import java.io.*; | |
import java.util.Scanner; | |
public class Create { | |
public static void main(String[] args) { | |
File file = new File("1.txt"); | |
try { | |
file.createNewFile(); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
// checked exception | |
try { | |
OutputStream fileOutputStream = new FileOutputStream(file); | |
char a; | |
PrintStream printStream = new PrintStream(fileOutputStream); | |
printStream.println("Sevval"); | |
printStream.flush(); | |
printStream.close(); | |
} catch (FileNotFoundException e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
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 com.birohcek; | |
import java.io.*; | |
import java.util.Scanner; | |
public class OutRedirect { | |
public static void main(String[] args) throws IOException { | |
File file = new File("wtf.txt"); | |
File sevval = new File("sevval.txt"); | |
boolean renamed = file.renameTo(sevval); | |
System.out.println("Isim degistirme: " + renamed); | |
// file.createNewFile(); | |
// | |
// | |
// FileOutputStream stream = new FileOutputStream(file, ); | |
// | |
// PrintStream out = new PrintStream(stream); | |
// System.setOut(out); | |
// | |
// System.out.println("Ben dosyaya gittim :/"); | |
// File sevvalKlasor = new File("sevval_klasor"); | |
// | |
// sevvalKlasor.mkdir(); | |
File yiit = new File("yiit.txt"); | |
FileInputStream fileInputStream = new FileInputStream(yiit); | |
Scanner scanner = new Scanner(fileInputStream); | |
int next = scanner.nextInt(); | |
System.out.println(next); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment