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 7 of 7

Thread: Java Project - Parsing & Implementation

  1. #1
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Java Project - Parsing & Implementation

    Hi Friends,

    I have been assigned a java based project.

    First based on environment variable values for any type of file extension such as .txt, .doc, .pdf etc. Example: FILE_EXT = .txt

    If FILE_EXT .txt
    then all .txt files in folders sub folders with should run a specific commands (such as command 1, command 2 & command 3.) related to .txt. Similarly for .doc (only specific to .doc), .pdf(only specific to .doc) etc.

    If FILE_EXT = .html
    then all .html files in folders sub folders with should skip above and run directly command 3.

    In all cases these files will be passed and returned from commands again.

    My question would be - how to pass environment variable as arguments and also, parsing for specific extension and running particular command.

    If any of you could help me with some ideas with snippets would be really helpful!

    Thanks,
    Paul


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Java Project - Parsing & Implementation

    Welcome Paul

    I do not completely understand the given instructions.
    Some keywords you may try searching: java parse regex
    Also your question is very general. Try to explain specifically what you are stuck on. For example, reading user input, reading file names, parsing strings, etc

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

    Default Re: Java Project - Parsing & Implementation

    Quote Originally Posted by jps View Post
    Welcome Paul

    I do not completely understand the given instructions.
    Some keywords you may try searching: java parse regex
    Also your question is very general. Try to explain specifically what you are stuck on. For example, reading user input, reading file names, parsing strings, etc
    jps, i havent started yet.

    These are my queries of confusions:
    1. How to pass parameter to commandline
    2. How to parse particular extension within folder and subfolders based on environment variable.
    3. All those files need to be passed to another "command" which converts the files to extension ".convert"
    4. all .convert files are passed to another command which processes and gives a modified ".convert" file.
    5. now after the latest .convert file is recieved, it is passed to another command which converts this .convert file to previous extension which was txt or doc whatever.
    6. Condition here would be if the file environment variable itself was .convert then step2 & step5 will not be done.

    These are requirements which needs to be done which i need guidance to achieve If anyone could explain with examples.

    Thank you!

  4. #4
    Junior Member
    Join Date
    Jun 2013
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Passing filename to execute command

    Hi,

    I am searching files based on extension. Now for each file found, want to run a command:

    Lets assume file found: C:\Home\1\1.txt
    My exe exists in: C:\Home\Hello.exe

    I would like to run command something like: "C:\Home\Hello.exe C:\Home\1\1.txt"

    similarly for C:\Home\ABC\2.txt - "C:\Home\Hello.exe C:\Home\ABC\2.txt"

    Kindly help me how to pass a searched file as an input to execute a command.

    Thanks,
    Kino

  5. #5
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Passing filename to execute command

    Uhm, what does it have to do with Java? There are no exe files in Java.

    What code are you using? Normally you'd use Runtime.exec() for that.
    When Runtime.exec() won't - JavaWorld

  6. #6
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Java Project - Parsing & Implementation

    That looks like a lot of work.
    Start with just one task and work on it first.
    Passing a parameter on the command line just means to type the parameter.
    Search keywords: java command line arguments: This is what I found
    Your questions are very generalized and make it difficult to provide much help without writing the code for you (which we do not do).
    If you need examples check with the API and Oracle tutorials, most of the time there are samples. Worst case scenario they will provide search keywords which should lead to examples.

  7. #7
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: Passing filename to execute command

    Please do not start a new thread to continue discussion of the same existing topic you also started.

    Threads merged.