Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2010
    Posts
    22
    Rep Power
    0

    Default java i/o question: where is stuff.txt???

    hello

    i am learning java on eclipse.

    if i am correct this program should output :

    "writing to output
    end of program"

    in eclipse and

    return "the quick brown bla bla" output in stuff.txt...i cant find stuff.txt in eclipse???????

    Java Code:
    package worksheet;
    
    import java.io.*;
    
    public class ABC {
    
    
    	
    
    	public static void main(String[] args)
    	
    	{
    		PrintWriter outputStream = null;
    		
    		try 
    		
    		{
    			outputStream = new PrintWriter(new FileOutputStream("stuff.txt"));
    			
    		}
    		
    		catch(FileNotFoundException e)
    		{
    			System.out.println("Error opening the file stuff.txt");
    			System.exit(0);
    		}
    		
    		System.out.println("Writing to file");
    		
    		outputStream.println("The quick brown fox");
    		outputStream.println("jumped pver the lazy dog");
    		
    		outputStream.close();
    		
    		System.out.println("End of program");
    		
    		
    	
    
    	}
    
    }

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,574
    Rep Power
    12

    Default

    new PrintWriter(new FileOutputStream("stuff.txt")

    Try doing this as a multi step process:

    * First create a new File("stuff.txt")
    * Then create the PrintWriter from that.

    That way you can use the appropriate File method to print the full path and name of the file you are using.

  3. #3
    JoKeR313 is offline Member
    Join Date
    Nov 2010
    Posts
    15
    Rep Power
    0

    Default

    I had this problem once before. My best guess is that your storing it in your src folder. Dont save it in that folder. You should be saving it in your (Project name) folder.

Similar Threads

  1. where the stuff goes?
    By Izabela in forum New To Java
    Replies: 16
    Last Post: 08-31-2010, 03:00 PM
  2. Replies: 6
    Last Post: 05-26-2010, 01:17 AM
  3. Replies: 5
    Last Post: 09-16-2009, 02:36 PM
  4. Looking for help on drawing stuff in a jPanel
    By Gatts79 in forum AWT / Swing
    Replies: 3
    Last Post: 08-28-2009, 07:00 PM
  5. Simple Stuff 0.1
    By Java Tip in forum Java Software
    Replies: 0
    Last Post: 07-19-2008, 05:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •