eclipse - I want java to create a new file with ...new PrintStream... it all works fine, but I can't find the file in my project -
I have a simple code similar to a digital math test (though only 1 question). I want to scan the program in the input window and want the result to print whether I was right or wrong in a new text file. The problem is that I can not accept the eclipse in my project, instead I want to do my projects Find the folder and get the .txt file instead. Is it possible to show the .txt file inside my project in Extensions? Thanks! ... Also, how do you put quotation marks inside quotation marks in Java? I mean "you answered" 500 "".
Package default; Import java.io.file; Import java.io.phileNotFoundException; Import java.io.PrintStream; Import java.util.Scanner; Public class mathstest {public static zero principal (string array []) filenoutfound exception {string Senate = "270"; String X; Printstream file = new printstream (new file ("test result. Txt")); Scanner scan = new scanner (System.in); System.out.println ("This is an exam, please answer the correct question."); System.out.println ("What is 50 * 50 / 100-20 + (800/20)?"); X = Scan. NXtine (); System.out.println ("This test concludes, the results of your test will be available in 'test results.'); If (x angle (cement)) {file.println ("you answered" + x); File.println ("That's right, well done!"); } Other {file.println ("You replied" + X + "."); File.println ("The correct answer was" + Canswer); File.println ("You have failed this exam."); }}}}
My first trend is not able to see your file, just you Do not refresh your project by right-clicking your project & gt; Click "Refresh" to see if your text file appears. Eclipse does not update your file system in real time, so you will need to refresh your project to see your updates.
For excerpts, you have to avoid quotes with the preceding forward slash, such as:
System.out.println ("She said," I do not eat vegetables . \ ""); This will be output:
She said, "I do not eat vegetables."
Comments
Post a Comment