Lost Password?


Go Back   CodeCall Programming Forum > Software Development > Java Help

Java Help Java Help forum discussing all Java platforms - J2ME, J2SE and J2EE - as well as relevant standards, APIs and frameworks such as Swing, Servlets, JSPs, Applets, Struts, Spring, Hibernate, ANT, EJB, and other Java-related topics.

Closed Thread
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-27-2006, 05:13 AM
xXHalfSliceXx's Avatar   
xXHalfSliceXx xXHalfSliceXx is offline
Co-Administrator
 
Join Date: Oct 2006
Location: Hendersonville, NC
Age: 24
Posts: 1,238
Rep Power: 20
xXHalfSliceXx is on a distinguished road
Send a message via AIM to xXHalfSliceXx Send a message via MSN to xXHalfSliceXx Send a message via Yahoo to xXHalfSliceXx
Post Java Test - 1

Find the error

Code:
import java.io.File;

public class DetermineFileDirExists {

    private static void doTest() {

        // Create a File object
        File file1 = new File("README_InputFile.txt");
        File file2 = new File("BlaBlaBla.txt");

        boolean b = file1.exists();
        System.out.println();
        System.out.println("Does File/Di " + file1 + " exist? (" + b + ")\n");

        b = file2.exists();
        System.out.println();
        System.out.println("Does File/Di " + file2 + " exist? (" + b + ")\n");


    }


    /**
     * Sole entry point to the class and application.
     * @param args Array of String arguments.
     */
    public static void main(String[] args) {
        doTest();
    }

}
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Company
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!

Sponsored Links
  #2 (permalink)  
Old 12-27-2006, 04:34 PM
dirkfirst dirkfirst is offline
Programming Professional
 
Join Date: May 2006
Posts: 338
Rep Power: 12
dirkfirst is on a distinguished road
Default

errr, hmm. What was the error message?
__________________
DirkFirst
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #3 (permalink)  
Old 12-27-2006, 11:10 PM
xXHalfSliceXx's Avatar   
xXHalfSliceXx xXHalfSliceXx is offline
Co-Administrator
 
Join Date: Oct 2006
Location: Hendersonville, NC
Age: 24
Posts: 1,238
Rep Power: 20
xXHalfSliceXx is on a distinguished road
Send a message via AIM to xXHalfSliceXx Send a message via MSN to xXHalfSliceXx Send a message via Yahoo to xXHalfSliceXx
Default

Find the error in the coding.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Company
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #4 (permalink)  
Old 12-29-2006, 01:06 PM
WingedPanther's Avatar   
WingedPanther WingedPanther is offline
Super Moderator
 
Join Date: Jul 2006
Age: 35
Posts: 3,418
Last Blog:
wxWidgets is NOT code ...
Rep Power: 37
WingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to beholdWingedPanther is a splendid one to behold
Default

I'd have to look at a reference, but it looks like you've got a timebomb waiting for you if file1 or file2 does NOT exist. file1 and file2 are not the filenames.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Programming is a branch of mathematics.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #5 (permalink)  
Old 01-04-2007, 01:20 AM
TkTech TkTech is offline
 
Join Date: Jun 2006
Posts: 1,033
Last Blog:
Having trouble with yo...
Rep Power: 20
TkTech is on a distinguished road
Send a message via MSN to TkTech
Default

Erm, I looked through this, and there is none...

[edit]
Proof of concept, I even compiled and ran it, works fine. Haha.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!

Sponsored Links
  #6 (permalink)  
Old 01-04-2007, 03:46 PM
John's Avatar   
John John is offline
Co-Administrator
 
Join Date: Jul 2006
Age: 20
Posts: 3,470
Last Blog:
Joomla! And Incompeten...
Rep Power: 20
John has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond reputeJohn has a reputation beyond repute
Send a message via AIM to John Send a message via MSN to John
Default

Code:
import java.io.File;
public class DetermineFileDirExists {
    private static void doTest() {
        // Create a File object
        File file1 = new File("README_InputFile.txt");
        File file2 = new File("BlaBlaBla.txt");
        boolean b = file1.exists();
        System.out.println();
        System.out.println("Does File/Di " + file1 + " exist? (" + b + ")\n");
        b = file2.exists();
        System.out.println();
        System.out.println("Does File/Di " + file2 + " exist? (" + b + ")\n");
    }
    /**
     * Sole entry point to the class and application.
     * @param args Array of String arguments.
     */
    public static void main(String[] args) {
        doTest();
    }
}
At first glance:
1. You included the proper class
2. You created a proper class header using proper naming conventions
3. You created a proper constructor giving it a private access modifer and making it static allowing you to use the method without having to create an instance of it
4. Proper syntax of a comment
5,6. Proper creation of a File object (which accepts a string, path can either be absolute or relative)
7. You created a variable b of the boolean type which is the correct type because exists() returns a boolean value
8,9. You print out the results with the proper use of string concatenation
10,11,12. Same as 7,8,9 respectivley
13. Close the constructor
14,15,16,17. Proper comment syntax
18. Proper creation of the main method
19. Proroper reference to the doTest() method. No instantiation needed being that doTest() is a static method
20. Closing of the main method
21. Closing of the class

Conclusion: No error

Test conclusion:
No compile errors, no run time errors, works if a file exists and if a file does not exist.

Ill be ****ed if there is an error

edit:
just not sure what the /Di is for

Last edited by John; 01-04-2007 at 03:53 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #7 (permalink)  
Old 01-08-2007, 01:08 AM
xXHalfSliceXx's Avatar   
xXHalfSliceXx xXHalfSliceXx is offline
Co-Administrator
 
Join Date: Oct 2006
Location: Hendersonville, NC
Age: 24
Posts: 1,238
Rep Power: 20
xXHalfSliceXx is on a distinguished road
Send a message via AIM to xXHalfSliceXx Send a message via MSN to xXHalfSliceXx Send a message via Yahoo to xXHalfSliceXx
Default

Quote:
Originally Posted by Sidewinder View Post
Code:
import java.io.File;
public class DetermineFileDirExists {
    private static void doTest() {
        // Create a File object
        File file1 = new File("README_InputFile.txt");
        File file2 = new File("BlaBlaBla.txt");
        boolean b = file1.exists();
        System.out.println();
        System.out.println("Does File/Di " + file1 + " exist? (" + b + ")\n");
        b = file2.exists();
        System.out.println();
        System.out.println("Does File/Di " + file2 + " exist? (" + b + ")\n");
    }
    /**
     * Sole entry point to the class and application.
     * @param args Array of String arguments.
     */
    public static void main(String[] args) {
        doTest();
    }
}
At first glance:
1. You included the proper class
2. You created a proper class header using proper naming conventions
3. You created a proper constructor giving it a private access modifer and making it static allowing you to use the method without having to create an instance of it
4. Proper syntax of a comment
5,6. Proper creation of a File object (which accepts a string, path can either be absolute or relative)
7. You created a variable b of the boolean type which is the correct type because exists() returns a boolean value
8,9. You print out the results with the proper use of string concatenation
10,11,12. Same as 7,8,9 respectivley
13. Close the constructor
14,15,16,17. Proper comment syntax
18. Proper creation of the main method
19. Proroper reference to the doTest() method. No instantiation needed being that doTest() is a static method
20. Closing of the main method
21. Closing of the class

Conclusion: No error

Test conclusion:
No compile errors, no run time errors, works if a file exists and if a file does not exist.

Ill be ****ed if there is an error

edit:
just not sure what the /Di is for
the error is in the /Di

it is suposed to be pointed to /Dir
Meaning Directory
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Company
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #8 (permalink)  
Old 01-08-2007, 07:17 PM
Jordan's Avatar   
Jordan Jordan is offline
Administrator
 
Join Date: Nov 2005
Location: Hendersonville, NC
Posts: 9,650
Last Blog:
PHP Objects, Patterns,...
Rep Power: 20
Jordan is just really niceJordan is just really niceJordan is just really niceJordan is just really nice
Send a message via ICQ to Jordan Send a message via AIM to Jordan Send a message via MSN to Jordan
Default

Hmm, that is a little hard to guess. How do we know that the creator didn't have a /Di directory?
__________________
CodeCall Blog | CodeCall Wiki | Shareware Site | Linux Forum | Write a Blog
The CodeCall Wiki is now fully integrated with vBulletin users! Check it out and add some new pages!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
  #9 (permalink)  
Old 01-08-2007, 08:24 PM
xXHalfSliceXx's Avatar   
xXHalfSliceXx xXHalfSliceXx is offline
Co-Administrator
 
Join Date: Oct 2006
Location: Hendersonville, NC
Age: 24
Posts: 1,238
Rep Power: 20
xXHalfSliceXx is on a distinguished road
Send a message via AIM to xXHalfSliceXx Send a message via MSN to xXHalfSliceXx Send a message via Yahoo to xXHalfSliceXx
Default

thats what i have been saying that I don't really like this example.

Closed. Make a new one.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum | My Company
Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
questions about java games stack Java Help 3 07-02-2007 06:35 PM
MS-SQL deadlock and hang the Java application reachpradeep Database & Database Programming 1 03-11-2007 05:20 AM
Java Facts techni68 Java Help 0 01-17-2007 02:41 PM
John's Java Tutorial Index John Java Tutorials 0 01-11-2007 04:05 PM
Java Help Files xXHalfSliceXx Java Help 3 11-29-2006 12:30 AM


All times are GMT -5. The time now is 11:21 PM.

Contest Stats

WingedPanther ........ 2753.6
Xav ........ 2704
Brandon W ........ 1702.32
John ........ 1207.73
marwex89 ........ 1175.24
morefood2001 ........ 966.05
dcs ........ 655.75
Steve.L ........ 475.59
orjan ........ 418.58
Aereshaa ........ 383.54

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 100%


Complete - Celebrate!

Ads