I´ve been searching for it and I found Encog and Neuroph but I don´t know if any about them... I've to do a final project and I need a litle feedback from humans, sometimes google is not enough XD
I have about 4 threads. One thread keeps checking some data that the other thread is updating. The others are doing some processing in the background. All have been started at this point.
My question is when the checking thread sees that the data has not been updated yet I currently sleep for a little bit but is there any way for me to tell the system to back to executing the thread that does the updating?
That or is there any way I can put something like a listener on the data(a String) and once its updated an event will fire that will do what it needs to do?
I tried using yield() and it seemed to just keep returning to the thread I called yield() from.
Thanks
I have one Map that contains some names and numbers
Map<String,Integer> abc = new TreeMap<String,Integer>();
It works fine. I can put some values in it but when I call it in different class it gives me wrong order. For example:
I putted
abc.put("a",1);
abc.put("b",5);
abc.put("c",3);
some time it returns the order (b,a,c) and some time (a,c,b).
What is wrong with it? Is there any step that I am missing when I call this map?
I have 1 thread who sole job is to grab DatagramPackets off of a socket and stick them in a buffer. Another thread works out of that buffer, processing the DatagramPackets. I'd like to have a pool of threads working out of that buffer.
I had thought to use a fixed thread pool to do this. To do so, do I need to create the pool, then submit enough runnables for execution to fill it up? I had hoped for a way to say "this is the thread/runnable that I want you to execute, this is how many I want running, GO!". Is there such a method of doing this? Is something other than a fixed thread pool better suited?
When I pass File file to a method I'm trying to get its full path like file.getAbsolutePath(); I always get the same result no matter which one I use either absolute or canonical path PATH_TO_MY_WORKSPACE/projectName/filename and it is not there, how can I get exact location of the file?
Thank you
Writing generated PDF (ByteArrayOutputStream) in a Servlet to PrintWriter.
I am desperately looking for a way to write a generated PDF file to the response PrintWriter.
Since a Filter up the hierarchy chain has already called response.getWriter() I can't get response.getOutputStream().
I do have a ByteArrayOutputStream where I generated the PDF into. Now all I need is a way to output the content of this ByteArrayOutputStream to the PrintWriter. If anyone could give me a helping hand would be very much appreciated!
There's a class I'm working with that has a display() function that prints some information to the screen. I am not allowed to change it. Is there a way to "catch" the string it prints to the screen externally?
I need to setup LookAndFeel Files in JDK 1.6.
I have two files:
napkinlaf-swingset2.jar
napkinlaf.jar
How can I set this up and use it?
I would like a GTK look and feel OR Qt look and feel, Are they available?
I have an Android app that communicates over a TCP socket with a server I wrote. The method I'm using now to read and write output works fine for smaller strings (up to 60kB) but I get an exception thrown when the string is much longer than that. Here is the relevant part of what I have for the server and client:
Server:
DataInputStream dis = null;
DataOutputStream dos = null;
try {
dis = new DataInputStream(server.getInputStream());
dos = new DataOutputStream(server.getOutputStream());
String input = "";
input = dis.readUTF();
handle_input info = new handle_input(input, id);
String xml = info.handle();
dos.writeUTF(xml);
server.close();
}
Client:
Socket socket = null;
DataOutputStream dos = null;
DataInputStream dis = null;
Boolean result;
try {
socket = new Socket(ip, port);
dos = new DataOutputStream(socket.getOutputStream());
dis = new DataInputStream(socket.getInputStream());
dos.writeUTF(the_text);
String in = "";
while (in.equals("")) {
in += dis.readUTF();
}
}
How can I modify it to deal with potentially enormous Strings? I've been looking around and can't seem to find a clear answer.
Thanks.
If we only need to graphically authorize a user,
view a few tables representation (from database),
ability to change data in the database visually
what tools to use to write such a web application that will run on Tomcat?
What framework allows to do that in the most straightforward, easy-to-manage and elegant way?
Problem/Task:
Write an interface with one method and two classes that implement this interface.
Now write a main method with an array that holds an instance of each class. Using a for-each loop, invoke the method upon each item.
Is this an interview question? (I'm not sure if the author meant to post this as a question or was looking for an answer to the above.)
Good Morning - it is school assignment, I am not asking for any source code (if you can provide any pesudo code it would be awesome).
Here is the problem :(
I have to create a term frequency table. It is not pure TF, I just need to count the words and write down.
I know basic steps to do it
1 - extract all terms (I can do it with file reader)
2 - remove repeating terms (I can do it with TreeMap)
The output of 2nd step would be
Niga, ponga, dinga, bitlo, etc.
3 - Now I have to see if there is any word in current file from above terms or not, if yes then I will count.
Now this is my problem, I stucked on step 3 :(
I have some idea how to count words with TreeMap (treemap.containskey etc.) but it would be global count not local count for each file :(
Any pseudo code?
Ok, so here is my problem:
I have a list containing interfaces - List<Interface> a - and a list of interfaces that extend that interface: List<SubInterface> b. I want to set a = b. I do not wish to use addAll() or anything that will cost more memory as what I am doing is already very cost-intensive. I literally need to be able to say a = b. I have tried List<? extends Interface> a, but then I cannot add Interfaces to the list a, only the SubInterfaces. Any suggestions?
EDIT
I want to be able to do something like this:
List<SubRecord> records = new ArrayList<SubRecord>();
//add things to records
recordKeeper.myList = records;
The class RecordKeeper is the one that contains the list of Interfaces (NOT subInterfaces)
public class RecordKeeper{
public List<Record> myList;
}
I am testing the performance of a data streaming system that supports continuous queries.
This is how it works:
- There is a polling service which sends data to my system.
- As data passes into the system, each query evaluates based on a window of the stream at the current time.
- The window slides as data passes in.
My problem is this, when I add more queries to the system, I should expect the throughput to decrease because it can't cope the data rate.
However, I actually observe an increase in throughput.
I can't understand why this is the case and I am guessing that it's something to do with the way the JVM allocates CPU, memory etc.
Can anyone shed any light to my problem?
I need to do a search in a map of maps and return the keys this element belong.
I think this implementation is very slow, can you help me to optimize it?.
I need to use TreeSet and I can't use contains because they use compareTo, and equals/compareTo pair are implemented in an incompatible way and I can't change that.
(sorry my bad english)
Map m = new TreeSet();
public String getKeys(Element element) {
for(Entry e : m.entrySet()) {
mapSubKey = e.getValue();
for(Entry e2 : mapSubKey.entrySet()) {
setElements = e2.getValue();
for(Element elem : setElements)
if(elem.equals(element)) return "Key: " + e.getKey() + " SubKey: " + e2.getKey();
}
}
}
I'm working on a small sketch in processing where I am making a "clock" using the time functions and drawing ellipses across the canvas based on milliseconds, seconds and minutes. I'm using a for loop to draw all of the ellipses and each for loop is inside its own method. I'm calling each of these methods in the draw function. However for some reason only the first method that is called is being drawn, when ideally I would like to have them all being visibly rendered.
//setup program
void setup() {
size(800, 600);
frameRate(30);
background(#eeeeee);
smooth();
}
void draw(){
milliParticles();
secParticles();
minParticles();
}
//time based particles
void milliParticles(){
for(int i = int(millis()); i >= 0; i++) {
ellipse(random(800), random(600), 5, 5 );
fill(255);
}
}
void secParticles() {
for(int i = int(second()); i >= 0; i++) {
fill(0);
ellipse(random(800), random(600), 10, 10 );
background(#eeeeee);
}
}
void minParticles(){
for(int i = int(minute()); i >= 0; i++) {
fill(50);
ellipse(random(800), random(600), 20, 20 );
}
}
Is it a good practice to set stream references to null after closing them? Would this release resources in any way?
Example:
BufferedReader input= new BufferedReader(new FileReader("myfile.txt"));
// code
input.close();
input = null;
// possible more code
I am trying to write a recursive method to print n number of asteriks in a line and create a new line at the end.
So, TriangleOps.line(5);
would print
*****
This is the code I wrote:
public static void line (int n){
if(n>0){
System.out.println("*");
line(n-1);
}}
instead it prints
*
*
*
*
*
with a lot of space at the end. Can anyone tell me how to remove the line breaks?
Hi, I have some classes and I'm trying to fill the objects of this class. Here is what i've tried. (Question is at the below)
public class Team
{
private String clubName;
private String preName;
private ArrayList<String> branches;
public Team(String clubName, String preName)
{
this.clubName = clubName;
this.preName = preName;
branches = new ArrayList<String>();
}
public Team() {
// TODO Auto-generated constructor stub
}
public String getClubName() { return clubName; }
public String getPreName() { return preName; }
public ArrayList<String> getBranches() { return branches; }
public void setClubName(String clubName) { this.clubName = clubName; }
public void setPreName(String preName) { this.preName = preName; }
public void setBranches(ArrayList<String> branches) { this.branches = branches; }
}
public class Branch
{
private ArrayList<Player> players = new ArrayList<Player>();
String brName;
public Branch() {}
public void setBr(String brName){this.brName = brName;}
public String getBr(){return brName;}
public ArrayList<Player> getPlayers() { return players; }
public void setPlayers(ArrayList<Player> players) { this.players = players; }
}
//TEST CLASS
public class test {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
String a,b,c;
String q = "q";
int brCount = 0, tCount = 0;
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
Team[] teams = new Team[30];
Branch[] myBranch = new Branch[30];
for(int z = 0 ; z <30 ;z++)
{
teams[z] = new Team();
myBranch[z] = new Branch();
}
ArrayList<String> tmp = new ArrayList<String>();
int k = 0;
int secim = Integer.parseInt(input.readLine());
while(secim != 0)
{
if(k!=0)
secim = Integer.parseInt(input.readLine());
k++;
switch(secim)
{
case 1 :
brCount = 0;
a = input.readLine();
teams[tCount].setClubName(a);
b= input.readLine();
teams[tCount].setPreName(b);
c = input.readLine();
while(c.equals(q) == false)
{
if(brCount != 0)
{c = input.readLine();}
if(c.equals(q)== false){
myBranch[brCount].brName = c;
tmp.add(myBranch[brCount].brName);
brCount++;
}
System.out.println(brCount);
}
teams[tCount].setBranches(tmp);
for(int i=0;i<=tCount;i++ ){
System.out.print("a :" + teams[i].getClubName()+ " " + teams[i].getPreName()+ " ");
System.out.println(teams[i].getBranches());}
tCount++;
break;
case 2:
String src = input.readLine();//LATERRRRRRRr
}
}
}
}
The problem is one of my class elements. I have an arraylist as an element of a class.
When i enter:
AAA as preName
BBB as clubName
c
d
e as Branches
Then as a second element
www as preName
GGG as clubName
a
b as branches
The result is coming like:
AAA BBB c,d,e,a,b
GGG www c,d,e,a,b
Which means ArrayList part of the class is putting it on and on. I tried to use clear() method but caused problems. Any ideas.
i want to list files starting with a name like "Report" from a folder.
i found this in google to list all files but i don't how to list file starting with a name.
Thank you
File directory = new File("C:\\Users\\kiki\\Downloads");
File[] files = directory.listFiles();
for (int index = 0; index < files.length; index++)
{
//Print out the name of files in the directory
System.out.println(files[index].toString());
}
Hello,
I have an object of CalendarEntry
I know that http://www.google.com/calendar/feeds/[email protected]/allcalendars/full is the feed url of all calendars
but how I can get this feed url from CalendarEntry instance?
Because I wanna post a new entry in a specified calendar and I need this url.
Thanks!