The question is when you send two messages from the client to the server does the server read the messages as one input or do you have to read both inputs on the server side?
Im using DataInputStream and DataOutputStream
On the client side I send two messages one for the database action to be performed and the send is the information needed to get the job done.
Example I want to search for a product in the database.
I send to the server an output message saying search product. I then send to the server which product I want to be searched.
The server then retrieves the message by in.readUTF(); switch statement determines what database action should be performed. Within that case I call another in.readUTF() to pass the information to the database on what product to search for.
Would this work or would the server read both messages from the client as one input stream?
Exception in thread "main" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(ImageIcon.java:205) at GUI.<init>(GUI.java:26) at Apples.main(Apples.java:7)
i think the problem is to do with my images not being recognised. I put them in my source in User>...>workspace>src which is correct as far as i know. From what i know the images should show up if i look at my src file in eclipse but they dont. I tried changing the file type from .png to .jpg but it makes no difference.
I'm trying to build a method that can search a binary search tree for a specific target and then return the number of probes it took to get there. It seems to me that the best way to do this would be a recursive search method and a counter that tracks the number of calls. But I'm struggling with how to implement this. Here's the code I have so far. what works/doesn't work with the method.
// Method to search the tree for a specific name and // return the number of probes public T search(BTNode<T> btNode) {
I have java program that I am debugging with NetBeans. In it I open a serial com port. It seems that if I exit the program the serial port is not closed so I cannot get the port the next time I start the program.
Is there a way I can detect that either the user clicked the "X" in the upper ight of the GUI or I clicked the "Stop Button" in NetBeans?
I just started learning Java, I was asked to write a simple program that prints a message if it encounters the number 7 or its multiple.
This should be achievable using simple loops and simple operations...
Here is my attempt:
Java Code:
Scanner scan = new Scanner(System.in); int i, j, temp; i = scan.nextInt(); // Awaiting user input j = scan.nextInt(); // Awaiting user input if (i > j){ // i = 10 j = 0 temp = i; // temp = 10
[Code]...
Now it works fine for numbers that are less than 70...
I am not sure what to do in case if for example 'i' and 'j' are very big numbers
I mean, I need it to detect the 7s even if it in the thousands place, actually - no matter how big is the number... So far I only made it to work for numbers that are less than 70...
I'm not even sure if I'm trying to place it in the correct area in the code. However I like to perform this prior to the receipt being displayed so if there a issue the user can correct this before the final receipt has been sent .......
i can use this current code to change it so that it use TextArea in jsp and the keylistener code in servlet. i know i have to take out the JFrame,JTextfield and ContentPane but still i could not do it.
i want to create an application which detect an image which took from camera and to process it so that it can be verified ..for example number plate of the vehicle ..if i need to extract the numbers from the image ..
I am new to java and i want to create an application which detect an image which took from camera and to process it so that it can be verified ..for example number plate of the vehicle ..if i need to extract the numbers from the image ..
My project builds a war. In the war there is a jar A which provides the implementation I1 of interface I. I1 is injected in a JSF controller. There is an optional jar B which provides another implementation I2 of interface I. I2 has an higher priority than I1. Is there a possibilty to achieve when jar B is present in the war I2 is injected. I tried it with @Alternative on I2 with an entry in beans.xml as alternative in jar B without success. I1 is injected. Something like a priority would be necessary. Or probably I am on a wrong way and there's another one that fits for my use case?
I would like to know how much of memory is free and used my java program.I have used Runtime.totalMemory and freeMemory() functions. However, how come used memory is so different than java.exe process show in windows task manager?
I am working on SpringMVC web application. Is there any way to detect from browser(jsp page) that any (exe) application is installed or not on client machine? And if not installed then show user the Popup to download that Application or Software . And if the user rejects to download that application then not allow him/her to login ....
I have a JTable with 5 columns, named: "ID", "Name", "UnitPrice", "Qty", and "Total". Only the columns UnitPrice and Qty are editable by the user. When, for example, for a row in the JTable, the user types 5000 in the UnitPrice column, and types 15 in the Qty column, I would want that when he types the first character in the Qty column (i.e. the character 1) in the Qty column, the Total column displays 5000*1, in other terms 5000.
And when the user types the second character in the Qty column, i.e the character 5, after having typed 1, the Total column should display 5000*15, in other terms 75000. So, to say it concisely, I would want that the Total column refreshes accordingly each time the user types a character in the Qty column. I have tried to use the MouseClicked event of the JTable, but noticed that that does not solve my problem. is there an event I should use to refresh my Total column? Or should I proceed in another fashion?
Here is the code I am trying to execute its giving me the error with TextReader..
import java.io.*; import java.util.*; public class WordCount { static TextReader in; // An input stream for reading the input file. static PrintWriter out; // Output stream for writing the output file.
[Code] .....
The error is:
C: eha>javac WordCount.java WordCount.java:20: cannot find symbol symbol : class TextReader location: class WordCount static TextReader in; // An input stream for reading the input file.
I've been wondering about this for a while. Is there any way to parallel I/O operations or is this a bad idea? If you could create two lists of good and bad ways to parallelize I/O.
i want to know when i have to use Flush in java , i saw alot of code that used it IO streaming , but i cannt understand how can i use it , or when i have to use it
I have a code that clear old text then add new text to text file afterthat download the file but the problem my code dose not add new text
FileInputStream fileToDownload ; private static final int BYTES_DOWNLOAD = 1024; response.setContentType("text/plain"); String name = request.getParameter("n"); String text = new String(request.getParameter("text").getBytes("iso-8859-1"), "UTF-8");
[Code] ....
How to clear old text then add new text to text file
Requirements - Use only standard Java API and no apache file utils for this.
Most of the answers I found on the internet either dont meet this requirement or load all file names into an array which can consume too much memory when no. of files = 20,000+. how I can do this. Is there also a way to keep track of new files that were added during the execution of the loop in this code ?