001package algs13; 002import stdlib.*; 003 004// Using a Queue as temporary storage for input of unknown size 005public class XClientQueue { 006 public static int[] readInts (String name) { 007 In in = new In (name); 008 Queue<Integer> q = new Queue<> (); 009 while (!in.isEmpty ()) 010 q.enqueue (in.readInt ()); 011 012 int N = q.size (); 013 int[] a = new int[N]; 014 for (int i = 0; i < N; i++) 015 a[i] = q.dequeue (); 016 return a; 017 } 018 public static void main (String[] args) { 019 int[] a = readInts ("data/tinyW.txt"); 020 StdOut.print (a.length); 021 } 022}