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

  • Home
  • SEARCH
  • 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 7308701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T23:35:39+00:00 2026-05-28T23:35:39+00:00

Proberly a very simple question, but within Java, I have a string as follows:

  • 0

Proberly a very simple question, but within Java, I have a string as follows:

public static String wincpuload = "cmd /c @for /f "skip=1" %p in ('wmic cpu get loadpercentage') do @echo %p%";

Although I get a syntax error because of some of the charcters in the string are breaking it. Similarly in C#, if you have this kind of problem you do:

string test = @"C:\testing\test"

How can you overecome this in java?

  • 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-05-28T23:35:39+00:00Added an answer on May 28, 2026 at 11:35 pm

    Just use a back slash (\) to escape your double quotes. Note the syntax highlighting below:

    Incorrect

    String s1 = "cmd /c @for /f "skip=1" %p in ('wmic cpu get loadpercentage') do @echo %p%";
    

    Correct

    String s2 = "cmd /c @for /f \"skip=1\" %p in ('wmic cpu get loadpercentage') do @echo %p%";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a very simple question. I have a script in the same folder
i have a very simple question I can't seem to get my head around.
This a data binding question in C#. I have a simple Person class: public
I'm aware that my question is very...plain and simple, but I'll ask it anyway:
I might be asking very simple question, but i am not able to get
I have what I believe to be an embarrassingly simple problem, but three hours
I have a simple question related to one-line programming. First an example: function test(a)
I've got (I hope) a very simple question for experts at MVC structure: where
I'm looking for a very simple way to communicate with a thread in Java.
I have a very simple application with a very strange behaviour. It's essentially the

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.