Skip to content

Instantly share code, notes, and snippets.

@LaurentiuGabriel
Created August 15, 2020 08:48
Show Gist options
  • Select an option

  • Save LaurentiuGabriel/4bca1ec1acb1b4b01b6e792edb6b9273 to your computer and use it in GitHub Desktop.

Select an option

Save LaurentiuGabriel/4bca1ec1acb1b4b01b6e792edb6b9273 to your computer and use it in GitHub Desktop.
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Scanner;
public class App {
public static void main(String[] args) throws IOException {
File file = new File("text");
Scanner scanner = new Scanner(file);
FileWriter fileWriter = new FileWriter(file);
fileWriter.write("Some Text");
fileWriter.flush();
fileWriter.close();
while(scanner.hasNext()){
System.out.print(scanner.next());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment