I've commented code like below :
/*System.out.println("Parsed in main : " + parsed);
System.out.println("Parsed sum " + (parsed.getHour() + parsed.getMinute()));
System.out.println(isSessionSelected("10:00:00 am"));*/
However, after organize import it disturb the import and look like this :
/*
* System.out.println("Parsed in main : " + parsed);
* System.out.println("Parsed sum " + (parsed.getHour() + parsed.getMinute()));
* System.out.println(isSessionSelected("10:00:00 am"));
*/
This eats my time as every time I uncomment code I have to remove extra *.
How to not let eclipse do this?
If you want to remove those extra *.
in eclipse go to
Window->Preferences->Java->Code Style->Formatter.
Create a new profile by clicking on new button.
after that a new dialog appears,
Select Comments tab
uncheck Enable block comment formatting.
Related
I'm using JPL Libraries to link a Prolog program with Java interface.
I have a (working) JTextArea where I redirect everything that appears in Console, but I can't see the prolog "write" instruction.
I used this method for queries:
Query q2 = new Query(t2);
System.out.println("Query " + t2 + " is " + (q2.hasSolution()));
but when the query is false, the text in "write" parts of Prolog for example:
write('Sorry, you can''t go from the '), write(CurPlace), write(' to the '), write(Place), nl,
doesn't appear in JTextArea.
I tried also with System.out.println("first solution of " + q2 + ": X = " + q2.oneSolution().get("X")); but it doesn't work.
What happen in JTextArea is this:
Query goto(garage).
is false
but I expected also the "write" warnings contained in .pl file. For example:
write('Sorry, you don''t have the keys')
I'm creating a csv file with data saved to it. The next thing i wanna do is that any person can download that file from a link in a HTML page.
The problem is I've never worked before with Java and I've searched for some good options but non of them seems to work. I hope any one can help me with this.
This is how is save to my CSV file
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class Logbook {
public Logbook() {
super();
}
/**
* #param date
* #param memoryMax
* #param memoryCommitted
* #param memoryUsed
* #param JvmUpTimeH
* #param JvmUpTimeD
* #param JvmUpTimeM
* #param JvmUpTimeS
*/
public void writeLog(String date, Long memoryMax, Long memoryCommitted, Long memoryUsed, String TotalTime) {
File Logbook = new File("C:/Logbook/Logbook.csv");
try (PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(Logbook, true)))) {
out.println(date + " , " + memoryMax + " b" + " , " + memoryCommitted + " b" + " , " + memoryUsed + " b" + " , " + TotalTime);
} catch (IOException e) {
// exception handling left as an exercise for the reader
}
}
}
After this I have a new page were it refreshes the page every sec my code to write it in the file is here
Long memoryUsed=agent.readMemoryUsed();
Long memoryCommitted=agent.readMemoryCommitted();
Long memoryMax=agent.readMemoryMax();
Date today2 = new Date();
SimpleDateFormat savedLog = new SimpleDateFormat("dd/MM/YY kk:mm:ss");
String date = savedLog.format(today2);
Logbook logBook = new Logbook();
logBook.writeLog(date, memoryMax,memoryCommitted,memoryUsed, TotalTime);
All I want now is to download the file with that information into it for any person that wanna download it.
Probably the easiest way to address this is to write the file to a location under your web server's file directory. You can serve this file statically - you don't need it to go through a webapp to provide it.
You don't mention what web server you're using, or even if you're using an application server on top of it, so we really can't help you that much more. If your question is actually about how to setup a web server - that gets beyond the scope of StackOverflow.
I have a tool what uses Perforce. When it merge a branch back to the parent, mark the project branch with checkout a text file, and submit it unchanged. This tool also use that text file, for read the actual build number. My problem is, a "/n" appeared in the text, and because it have to contain just numbers, it's a big problem.
Have anyone met this problem, or this can't caused by P4C?
Maybe important, I don't use P4JAVA here.
Please note that I'm debugging right now, and I'm not sure the problem is here, but at the moment this seems the most probable.
//<path> is a legit path, I just shortened the code here
commandSync = "p4 -d " + getPerforceRoot() + " sync " + selectedDataBean.getP4Path() + "<path>/BuildNum.txt";
CommandResultBean syncCommandResult = commandExecuter.runAndGetResults(commandSync);
//command executer that runs the command string in cmd
commandMark = "p4 -d " + getPerforceRoot() + " edit -c " + changelistNumber + " " + selectedDataBean.getP4Path() + "<path>/BuildNum.txt";
CommandResultBean markCommandResult = commandExecuter.runAndGetResults(commandMark);
commandSubmit = "p4 -d " + getPerforceRoot() + " submit -f submitunchanged -c " + changelistNumber;
CommandResultBean submitCommandResult = commandExecuter.runAndGetResults(commandSubmit);
I have the below code and on my computer via Eclipse virtual device it works fine. But when installed on a real life phone it always reverts to the else statement.
This activity does not always get passed a value and if it is not I want a random record to appear. Thank you for any help or advice and time taken to read.
searchId = getIntent().getIntExtra("EMPLOYEE_ID", 0);
if(searchId > 0){
Query="SELECT * FROM " + DB_TABLE +" ORDER BY RANDOM() LIMIT 1";
Log.v("STANDARD RANDOM", "Was run");
}
else{
Query ="SELECT * FROM " + DB_TABLE +" WHERE _id=" + searchId + "";
Log.v("FROM SEARCH PAGE", "Was run");
}
Not sure if this fixes your problem. But according to the documentation, your code is not correct:
The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
Taken from Intent.putExtra.
You are using "EMPLOYEE_ID", without a package prefix, but you must include one!
I got my inv finally working! :D But, you know... now... it's dumb. I want it to say "Use Item 1" or whatever when I Right-click so I do this:
if (actItemx == "Item 1") {
popup.add(dropMenuItem + " " + actItemx); // should print "Use Item 1"
popup.add(cancelMenuItem);
}
Looks fine to me... but... when I compile, it's fine. When I run it, it's fine... but when I DO IT:
I would have sworn that because it's displayed correctly in CMD that it would display correctly on JMenu... weird.
popup.add(dropMenuItem + " " + actItemx);
That command is adding the toString() representaion of the dropMenuItem Swing component, plus a space, the the String value of actItemx.
I would guess you want:
popup.add(dropMenuItem.getText() + " " + actItemx);