Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Help > File I/O Advice...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 5 Topic 15852 of 16566
Post > Topic >>

File I/O Advice needed....

by TheBigPJ <TheBigPJ@[EMAIL PROTECTED] > Mar 4, 2008 at 04:14 PM

Which the latest file i/o mechanism to use?

I know this doesn't matter but I think I have mixed up the version
mechanisms,

Thanks,
Peter

------------------------------------------------
im****t java.util.Random;
im****t java.io.*;

public class Goody
{
    public static void main(String[] args)
    {
        Goody a = new Goody();
        a.theStart(args[0]);
    }

    void theStart(String temp)
    {
    int numbersRequired = Integer.parseInt(temp);
    int[] tempNumbers = new int [numbersRequired];

    try {
        /*FileOutputStream fos = new FileOutputStream ("E:/Temp/
data.text");

        for(int i = 0; i < numbersRequired; i++)
            new PrintStream(fos).println(new Random().nextInt(214));

        fos.close();*/
        //The above code also works

        PrintWriter out = new PrintWriter(new FileWriter("E:/Temp/
data.text"));

        for(int i = 0; i < numbersRequired; i++)
            out.println( new Random().nextInt(214));
        out.close();

        BufferedReader in = new BufferedReader(new FileReader("E:/Temp/
data.text"));

        for(int i = 0; i < numbersRequired; i++)
            tempNumbers[i] = Integer.parseInt(in.readLine());

        in.close();
        }
    catch(Exception e)
    {
    }

    for(int  j = 0; j < numbersRequired; j++)
        System.out.println(j + ":" + tempNumbers[j]);
    }
}
 




 5 Posts in Topic:
File I/O Advice needed....
TheBigPJ <TheBigPJ@[EM  2008-03-04 16:14:45 
Re: File I/O Advice needed....
Eric Sosman <esosman@[  2008-03-04 20:28:22 
Re: File I/O Advice needed....
Roedy Green <see_websi  2008-03-05 08:14:09 
Re: File I/O Advice needed....
Lew <lew@[EMAIL PROTEC  2008-03-05 08:04:05 
Re: File I/O Advice needed....
TheBigPJ <TheBigPJ@[EM  2008-03-05 12:30:18 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 13:43:28 CST 2008.