Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Why Can't my file be read?

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Why Can't my file be read?

    import java.io.File;
    import java.io.IOException;
    import java.io.PrintWriter;
     
    import java.util.Scanner;
     
     
     
    public class StockAnalysis {
     
    	public static void main(String [] args) {
     
    		StockDataBase startingvalue = new StockDataBase(0);
     
    		StockDataBase endingvalue = new StockDataBase(0);
     
     
     
     
     
    		try {
     
    			Scanner input = new Scanner(new File("values.txt"));
     
    			PrintWriter output = new PrintWriter("values.txt");
     
     
     
     
    			output.println("2013");
     
    			int n =0;
     
    			int m =0;
     
    			for(int i = 0; i<=365; i++) {
     
    				 n =(int)(Math.random());
    				m =(int)(Math.random());
     
    			output.println(DayConverter.getDateString(i, false));
     
    			startingvalue= new StockDataBase(n);
     
    			endingvalue= new StockDataBase(m);
     
    			output.println(startingvalue);
     
    			output.println(endingvalue);
     
    			}
     
     
     
     
     
     
    				while(input.hasNext()) {
     
     
    				String year= input.next();
     
    				}
     
    				while(input.hasNextInt()) {
     
    				int year = input.nextInt();
     
    				int start =input.nextInt();
     
    				int end = input.nextInt();
     
    				startingvalue= new StockDataBase(start);
     
    				endingvalue= new StockDataBase(end);
     
    				System.out.println("" + "           "   +   year);
     
    				System.out.println("-------------------------------");
    				System.out.println(startingvalue + " " + endingvalue);
     
     
     
    				}
    				input.close();
     
     
     
     
     
     
     
    		} catch (IOException e) {
     
    			System.out.println("Unable to open or read from file. ");
    		}
     
     
    }
    }


  2. #2
    Junior Member
    Join Date
    Jul 2013
    Location
    noida
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Why Can't my file be read?

    i dont no but plz u send me this problem i check it beacuse same problem in my side

  3. #3
    Junior Member
    Join Date
    Apr 2013
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Why Can't my file be read?

    Quote Originally Posted by dwivedisandeep207 View Post
    i dont no but plz u send me this problem i check it beacuse same problem in my side
    What do you want me to do?

  4. #4
    Junior Member
    Join Date
    May 2013
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Why Can't my file be read?

    Are you using an IDE for this?

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: Why Can't my file be read?

    Why Can't my file be read?
    You tell us...are there exceptions? If so, you should print at least the stack trace to get an idea of what's going on.

  6. #6
    Banned
    Join Date
    Jul 2013
    Posts
    49
    Thanks
    1
    Thanked 5 Times in 4 Posts

    Default Re: Why Can't my file be read?

    what kind of errors are displayed...?

Similar Threads

  1. help with GUI .. read file and write file
    By kernal in forum What's Wrong With My Code?
    Replies: 2
    Last Post: May 14th, 2012, 10:38 AM
  2. Read input, read file, find match, and output... URGENT HELP!
    By MooseHead in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 3rd, 2012, 11:01 AM
  3. [SOLVED] Jar file to read text file from within itself
    By KILL3RTACO in forum Java Theory & Questions
    Replies: 2
    Last Post: October 24th, 2011, 06:34 PM
  4. Java I/O File code; how to read/write file
    By ryu2le in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 18th, 2011, 05:51 PM
  5. Read a text file and parse the contents of file
    By HelloAll in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: March 3rd, 2011, 05:47 AM