Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8305471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:07:24+00:00 2026-06-08T18:07:24+00:00

I have cmd like this one: java Test -p 127.0.0.1:8080 -d D:\Desktop\temp.exe -o mingw

  • 0

I have cmd like this one:

java Test -p 127.0.0.1:8080 -d D:\Desktop\temp.exe -o mingw -s 1024 -t 2000

I want to get the args with -p,-d or -s(exclude -p,-d,-s itself), and discard other args.

I tried hours but had no result,is there any one can help me?

I tried the arg[i] and arg[i+1] way,but if args like this:-p -d xxx, the user do not enter -p value, this solution will take no effect and cause problems.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:07:25+00:00Added an answer on June 8, 2026 at 6:07 pm

    If all your options are in same form -x value, then you can split your args array into groups in form of -d 127.0.0.1:8080, -d D:...

    for(int i=0; i < args.length; i+=2){
        //group args
    }
    
    for each group in groups:
        if group[0].equals("-d"){
              //do something
        }
    }
    

    Or, just have a look at existing OptionParser libraries in Java. How to parse command line arguments in Java?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

my code goes like this: Runtime rt = Runtime.getRuntime(); // cmd == cmd.exe /C
I have a simple menu, something like the following: while(cmd != quit){ cin >>
I have this code: con.Open(); cmd = new MySqlCommand(String.Format(SELECT concat(name,'|',lastname) FROM {0} WHERE ID=
Here is what I have: process = subprocess.Popen([cmd.exe, /c appcfg.py, upload_data, --config_file=..\\bulkloader.yaml, --filename= +
I have a query like this: SELECT TaFellesVaktjournal.*, TaBygg.ByggNavn FROM TaFellesVaktjournal LEFT JOIN TaBygg
I have seen references to similar issues, but not this exact one. I have
I am implementing a command line program which has interface like this: cmd [GLOBAL_OPTIONS]
I have application which loads images like this: someImage = Image.FromFile(@picture.png); and another application
I have an SP with some condition like this IF NOT EXISTS (Select *
I used to have this one Dt = MyMod.GetDataTable(SELECT TOP & QuestionsPerCats(i) & *

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.