so i have a little issue here. i have a program that creates a list of random numbers, for sake of example here it is:
public class RandomSeq
{
public static void main(String[] args)
{
int n = Integer.parseInt(args[0]);
for (int i = 0; i < n; i++)
System.out.println(Math.random());
}
}
now my textbook says that all i have to do to get the output of this program to go into a text file is to type "java RandomSeq 10 > data.txt". this should make a text file (data.txt) that has a list of ten random doubles between 0 and 1 . but in reality what happens is it just sort of ignores the " > data.txt" part and just prints the ten random doubles in the console. the textbook also tells me that i can use a similar line of code to use a text file as imput (with standard input). for example if i have a program that uses the list of ten doubles as input i could type "java inputprogram < data.txt". but this also doesnt work.
so my question is to all you java gurus. is there something i need to do for this type of thing to work? i would assume that the textbook is not wrong in what it is saying to do, i wrather think there is something missing from either my compiler or some basic methods or something.
EDIT:
ps. if you go to http://www.cs.princeton.edu/introcs/15inout/ and look at some of the examples in the "redirecting and piping" and "standard drawing" sections as you scroll down, you can see what i mean. the " | sort" and " | more" commands would go under the same category i guess.. how can i get these to work?