-
-
Save fado/d48ae3508a5398867099 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 FileWriter; | |
import java.io.PrintStream; | |
import java.io.File; | |
import java.io.FileNotFoundException; | |
import java.util.Scanner; | |
import java.util.Random; | |
public class FileWriter { | |
public static void main(String[] args) throws FileNotFoundException { | |
PrintStream writer = new PrintStream(new File("randInts.txt")); | |
Scanner scanner = new Scanner(System.in); | |
System.out.print("How many digits?: "); | |
int numberOfDigits = scanner.nextInt(); | |
Random random = new Random(); | |
for (int counter = 0; counter < numberOfDigits; counter++) { | |
writer.print(random.nextInt(10)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment