Hello guys,
One thing I want to know is how to calculate what date will it be 10 days from today.
Second thing is to check if one Date is between two other Dates.
For example, let's say I have an app that shows what events I need to do in the next 10 days (planner). Now how can I see if the date I assigned to an event is between today and the date that is 10 days from today?
Is anybody out there using Project Lombok for a large scale production system? How does it influence your compile process (i.e. does it do two-pass compilation, slow it down, make it more fragile)?
A JSpinner is used to store a number in my application (with a SpinnerNumberModel).
As expected, the spinner doesn't allow invalid characters (letters, symbols, etc.) to be stored. However, those characters do appear in the spinner component when I type them in. As soon as I switch the focus to another component, they disappear.
Is there a way to prevent invalid characters from appearing in the spinner?
Hello,
I want to optimize this code:
InputStream is = rp.getEntity().getContent();
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String text = "";
String aux = "";
while ((aux = reader.readLine()) != null) {
text += aux;
}
The thing is that i don't know how to read the content of the bufferedreader and copy it in a String faster than what I have above.
I need to spend as little time as possible.
Thank you
I have imported a WSDL and use it to send a SOAP request. It looks like this:
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<version xmlns="http://www.tempuri.org">
<parRequest xmlns="">
<faturaUUID>[string?]</faturaUUID>
<faturaNo>[string?]</faturaNo>
<faturaReferansNo>[string?]</faturaReferansNo>
<durumKodu>[int]</durumKodu>
<durumAciklamasi>[string?]</durumAciklamasi>
</parRequest>
</version>
</Body>
</Envelope>
But I want to remove
xmlns=""
such as
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
<Body>
<acceptResponse xmlns="http://tempuri.org/">
<responseRes>
<faturaUUID>[string?]</faturaUUID>
<faturaNo>[string?]</faturaNo>
<faturaReferansNo>[string?]</faturaReferansNo>
<durumKodu>1</durumKodu>
<durumAciklamasi>[string?]</durumAciklamasi>
</responseRes>
</acceptResponse>
</Body>
</Envelope>
My web service code:
@WebService(serviceName = "test", targetNamespace = "http://www.tempuri.org")
public class ErpEntServ {
@WebMethod(operationName = "version")
public String version(@WebParam(name = "parRequest") acceptResponse acceptResponse) {
return "0";
}
how to remove it?
I try to @WebParam(name = "parRequest",targetNamespace = "http://www.tempuri.org") acceptResponse acceptResponse but it did not.
Thank you for helping
Okay I got this function who prints the name of all files in a directory recursively problem is that it's very slow and it gets the stuff from a network device and with my current code it has to access the device time after time.
What I would want is to first load all the files from the directory recursively and then after that go through all files with the regex to filter out all the files I don't want. Unless anyone got a better suggestion. I've never before done anything like this.
public static printFnames(String sDir){
File[] faFiles = new File(sDir).listFiles();
for(File file: faFiles){
if(file.getName().matches("^(.*?)")){
System.out.println(file.getAbsolutePath());
}
if(file.isDirectory()){
printFnames(file.getAbsolutePath());
}
}
}
This is just a test later on I'm not going to use the code like this, instead I'm going to add the path and modification date of every file which matches an advanced regex to an array.
I am using this code to find the MAC address of a machine.This code prints directly the MAC address, but i want to return it as a string.I am completely confused.
please help.
try {
InetAddress add = InetAddress.getByName("10.123.96.102");
NetworkInterface ni1 = NetworkInterface.getByInetAddress(add);
if (ni1 != null) {
byte[] mac1 = ni1.getHardwareAddress();
if (mac1 != null) {
for (int k = 0; k < mac1.length; k++) {
System.out.format("%02X%s", mac1[k], (k < mac1.length - 1) ? "-" : "");
}
} else {
System.out.println("Address doesn't exist ");
}
System.out.println();
} else {
System.out.println("address is not found.");
}
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (SocketException e) {
e.printStackTrace();
}
Please explain the output of the below code:
If I call th1.run() ,the output is
EXTENDS RUN
RUNNABLE RUN
If I call th1.start() , the output is :
RUNNABLE RUN
EXTENDS RUN
Why this inconsistency . Please explain.
class ThreadExample extends Thread{
public void run(){
System.out.println("EXTENDS RUN");
}
}
class ThreadExampleRunnable implements Runnable {
public void run(){
System.out.println("RUNNABLE RUN ");
}
}
class ThreadExampleMain{
public static void main(String[] args){
ThreadExample th1 = new ThreadExample();
//th1.start();
th1.run();
ThreadExampleRunnable th2 = new ThreadExampleRunnable();
th2.run();
}
}
This is my code...
class info{
public static void main (String[]args) throws IOException{
char gen;
while(true) { //problem occurs with this while
System.out.print("\nENTER YOUR GENDER (M/F) : ");
gen=(char)System.in.read();
if(gen=='M' || gen=='F' || gen=='m' || gen=='f'){
break;
}
}
System.out.println("\nGENDER = "+gen);
}
}
This is my output...
ENTER YOUR GENDER (M/F) : h
ENTER YOUR GENDER (M/F) :
ENTER YOUR GENDER (M/F) :
ENTER YOUR GENDER (M/F) : m
GENDER = m
Could someone please help me understand why it is asking for the gender so many times.
I have:
Image i = Image.getInstance("tabelka.png");
i.scalePercent(25, 25);
for(int i=0; i<= 5; i++)
{
doc.add(i);
content.moveTo(50, ??);////// <-------------- HOW TO CHECK THE Y POSITION
content.showText("skowron-line");
}
I want to set text on upper right corner of image. How do I do that?
EIDT:
After hours of thinkin i found dirty solution:
Image img = Image.getInstance("tabelka.png");
img.scalePercent(25, 25);
float start = x;
for(int i =1; i<= 5; i++)
{
start = (x - (img.getHeight() * 0.25f) * i);
}
If U know better solution let me know.
hi everyone,
I work on inheritence with GUI (graphical user interfaces)
let me explain for example I made super class which is vehicle and the subclass is car, so the code to make inheritence will be
public class Car extends Vehicle
then I want to build the class Car as JFrame like
public class Car JFrame implements ActionListener {
so the problem is that I couldn't put both codes in the same class, and I need to do that.
anyone help me. thanks in advance
I wish that the question would be clear
public class b {
public static void main(String[] args) {
byte b = 1;
long l = 127;
// b = b + l; // 1 if I try this then it does not compile
b += l; // 2 if I try this then it does compile
System.out.println(b);
}
}
I am using this code but I have problem:
I don't understand why b=b+l; is not compiling but if I write b+=l; then it compiles and runs.
Please explain why this happens.
Hello,
what behaviour can I expect when I run this code:
do while(testA) {
// do stuff
} while(testB);
Will it behave like:
do {
while(testA) {
// do stuff
}
} while(testB);
Or:
if(testA) {
do {
// do stuff
} while(testA && testB);
}
Or something totally unexpected?
I ask this question because I think this is quite ambiguous, and for other people searching on this topic, not because I am lazy to test it out.
Hi, what is the best practice or best way of passing form parameters from page to page in a flow? If I have a flow where a user enters data in a form and hits next and repeats this process until they get to an approval page, what ways could I approach this problem to make the retention of data as simple as possible over the flow?
I guess you could put all the information as you go in the session but could you get into memory issues if a lot of people are using your app and going through the flow at the same time?
I know that when creating buttons, like next and previous, that the code can be somewhat long to get those buttons to function.
My professor gave us this example to create the next button:
private void jbtnNext_Click() {
JOptionPane.showMessageDialog(null, "Next" ,"Button Pressed",
JOptionPane.INFORMATION_MESSAGE);
try {
if (rset.next()) {
fillTextFields(false);
}else{
//Display result in a dialog box
JOptionPane.showMessageDialog(null, "Not found");
}
}
catch (SQLException ex) {
ex.printStackTrace();
}
}
Though, I do not really understand how that short and simple if statement is what makes the next button function. I see that the fillTextFields(false) uses a boolean value and that you need to initialize that boolean value in the beginning of the code I believe. I had put private fillTextFields boolean = false; but this does not seem to be right...
I'm just hoping someone could explain it better. Thanks :)
I want to store an object from my class in file, and after that to be able to load the object from this file. But somewhere I am making a mistake(s) and cannot figure out where. May I receive some help?
public class GameManagerSystem implements GameManager, Serializable {
private static final long serialVersionUID = -5966618586666474164L;
HashMap<Game, GameStatus> games;
HashMap<Ticket, ArrayList<Object>> baggage;
HashSet<Ticket> bookedTickets;
Place place;
public GameManagerSystem(Place place) {
super();
this.games = new HashMap<Game, GameStatus>();
this.baggage = new HashMap<Ticket, ArrayList<Object>>();
this.bookedTickets = new HashSet<Ticket>();
this.place = place;
}
public static GameManager createManagerSystem(Game at) {
return new GameManagerSystem(at);
}
public boolean store(File f) {
try {
FileOutputStream fos = new FileOutputStream(f);
ObjectOutputStream oos = new ObjectOutputStream(fos);
oos.writeObject(games);
oos.writeObject(bookedTickets);
oos.writeObject(baggage);
oos.close();
fos.close();
} catch (IOException ex) {
return false;
}
return true;
}
public boolean load(File f) {
try {
FileInputStream fis = new FileInputStream(f);
ObjectInputStream ois = new ObjectInputStream(fis);
this.games = (HashMap<Game,GameStatus>)ois.readObject();
this.bookedTickets = (HashSet<Ticket>)ois.readObject();
this.baggage = (HashMap<Ticket,ArrayList<Object>>)ois.readObject();
ois.close();
fis.close();
} catch (IOException e) {
return false;
} catch (ClassNotFoundException e) {
return false;
}
return true;
}
.
.
.
}
public class JUnitDemo {
GameManager manager;
@Before
public void setUp() {
manager = GameManagerSystem.createManagerSystem(Place.ENG);
}
@Test
public void testStore() {
Game g = new Game(new Date(), Teams.LIONS, Teams.SHARKS);
manager.registerGame(g);
File file = new File("file.ser");
assertTrue(airport.store(file));
}
}
I want to create a program for generating the series for the given base-n. ,
for example if my input is 2,then series shuould be, 00,01,10,11,etc.,(binary)
if my input is 10,then series shuould be,1,2,3,4,5,etc.,(decimal)
is there any general mechanism to find these numbers so that I can program for base-n.,
type first integer , type second integer, , program repeatedly outputs the second value of the number of times indicated by the first value. Example use inputs 4 and 2, 222 2 displayed. another example user inputs 3 and 8 , 88 8 displayed
Hello
I have this configuration for ehCache:
<ehcache>
<defaultCache
name="defaut"
maxElementsInMemory="5"
eternal="false"
timeToIdleSeconds="20"
timeToLiveSeconds="20"
overflowToDisk="false"
diskPersistent="false"
memoryStoreEvictionPolicy="LRU"
/>
</ehcache>
How can I get access to default cache of EhCache?
CacheManager.getInstance().getCache("default") - returns null
thank you
Hy ,what i`m trying to do is something like this:
private class aClass
{
private ArrayList idProd;
aClass(ArrayList prd)
{
this.idProd=new ArrayList(prd);
}
public ArrayList getIdProd()
{
return this.idProd;
}
}
So if i have multiple instances of ArrayLIst (st1 ,st2 ,st3) and I want to make new objects of aClass :
{
aClass obj1,obj2,obj3;
obj1=new aClass(st1);
obj2=new aClass(st2);
obj3=new aClass(st3);
}why all of the aClass objects will return st3 if I access the method getIdProd() for each of them(obj1..obj3)? is an arraylist as a instance variable automatically declared static?
about = new JMenuItem("About");
about.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A((Toolkit.getDefaultToolkit().getMenuShortcutMask()))));
JMenu help = new JMenu("Help");
help.add(about);
I was wondering why my aaccelerators were not working. I am running this in snow leopard with JavaSe-1.6 VM. They do work if I pull the menu down then try the key sequence. Thanks
Hi guys,
I have a Spring application that I believe has some bottlenecks, so I'd like to run it with a profiler to measure what functions take how much time. Any recommendations to how I should do that?
I'm running STS, the project is a maven project, and I'm running Spring 3.0.1
Cheers
Nik