Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Lab 4
- import java.util.*;
- import java.io.*;
- public class read{
- public static void main(String[] args) throws Exception{
- try {
- File nfile = new File("Excercise12_15");
- PrintWriter outdata = new PrintWriter( nfile );
- for (int i = 0; i< 100; i++) {
- int x = 0;
- x = (int) (Math.random()*1000);
- outdata.print(x + " ");
- if (i == 99) {
- outdata.close();
- }
- }
- Scanner nin = new Scanner( nfile );
- int x = 0;
- ArrayList<Integer> array = new ArrayList<Integer>();
- while(nin.hasNext()) {
- array.add(nin.nextInt());
- }
- array.sort(null);
- System.out.println(array);
- }catch (IOException exp) {
- System.out.println("Unable To Write Data.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement