Results 1 to 7 of 7

Thread: Java Netbeans 3.5.1

  1. #1
    Join Date
    Aug 2004

    Java Netbeans 3.5.1

    Hi all,
    Just wondering if you could help me out a bit with netBeans (the help file is no good at this).
    What i want to do is just write a simple java program that takes input. Now i know how to pass arguments on their own (Build > Set Arguments) which works as if the user was typing the arguments at the command prompt, but i need to be able to do the same but the program should read from a file. Basically when you use the command prompt you would type 'java javaFile fileToPass.txt' to make the javaFile read input from fileToPass.txt (obviously its been compiled first).
    However, i have got some problems at command prompt and would prefer to just use netBeans to read from a file.
    Does anyone know how i can do this in netBeans.
    Thank you.

  2. #2
    Join Date
    Nov 2003
    I don't do netBeans, but perhaps I can ask a question to help clarify for others what the exact thing you need help with...

    Is the question basically, "How do I read a file using netBeans?"

    Or do you actually know how to read a file, but you're looking for a way to use it as a substitute for command line arguments? (In which case, I'd suggest using XML for the file and storing the info in the form of parameter name + parameter value. Then parse out the parameters and associated values, if any, and take the appropriate action.)

  3. #3
    Join Date
    Aug 2004

    The answer to this is your sentence as follows:

    'Or do you actually know how to read a file, but you're looking for a way to use it as a substitute for command line arguments? '

    However, i am not that experienced as a programmer and therefore have basically no idea what this means :

    'I'd suggest using XML for the file and storing the info in the form of parameter name + parameter value. Then parse out the parameters and associated values, if any, and take the appropriate action'

    Thank you.

  4. #4
    Join Date
    Nov 2003
    OK, so you know how to open and read files.

    What I'm suggesting is that you use XML for the formatting of the file you read the parameters from.

    You could read in values from the XML file sequentially, which would correspond to using commandline parameters that were used by their order: foo.exe 1 blah

    Or you could assign names and values to parameters, giving you much more flexibility and corresponding to a command line where parameters have a name specified first, followed by their value: foo.exe -count 1 -word blah

  5. #5
    Join Date
    Aug 2004

    Red face

    Oops I am sorry, I think I read your sentence about :

    'Or do you actually know how to read a file, but you're looking for a way to use it as a substitute for command line arguments? '

    rather lightly. I dont actually know how to read a file (of inputs) that java should look in. I was thinking more along the lines of do i know how to open a java file in netBeans (like you would in Microsoft word or something), i know it sounds rather ignorant :-D

    Let me put it as simple as i can, when you run some java program that you have made that prompts you to input some value(s) what you would do at that point (when it prompts you) is to type it in. Instead of typing in the values manually i would like to put them in a file (for example if there are many values and i dont wish to type them in or paste them everytime). Then i can use the command

    java someJavaFile < someFileToRead

    i cant remember for sure whether its < or > but its to that effect.
    Then what java will do is to take (when it prompts) the inputs from that file (every line is like typing at a new prompt - i can set it up that way) as if it was an input from you physically typing it at the keyboard. I would just like to know how you can do this in netbeans or if it is at all possible to do it in netBeans since you can do it at the command prompt.
    Thank you and sorry for the trouble.

  6. #6
    Join Date
    Nov 2003
    For command line standard IO redirection:
    < is input
    > is output

    I know practically nothing about netBeans, so I can't really be of much help...

    I still am somewhat confused by exactly what you're looking for... Do you mean that for just one component (netBean), you want to be able to redirect standard input to come from a file? Just that component, and not the rest of the application it is used in?

    Hmmm... Maybe I get it now... is the netBean a GUI component, not using a console? In which case, I have no idea if you can redirect input. However, if nothing else, you should be able to slap together an ad hoc solution along the lines of what I proposed earlier.

  7. #7
    Join Date
    Dec 2002
    Calgary, Canada
    name of the file that you are trying to pass is just another parameter...create a file object in the main method...suppose the input wil only have 1 parameter and that will be a file

    File file = new File(args[0]);

    and then you can use file object to read it thru....ofcourse you will have to write error handlings and such...but above is the basic logic sto start with.


    Message Posting Guidelines In These Forums, Please read these before posting any question.
    Web site: webapplikations.com
    Web Resources Page:Web Resources

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13974 seconds
  • Memory Usage 2,889KB
  • Queries Executed 13 (?)
More Information
Template Usage (32):
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (7)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates