|
1: procedure AllocateVM(VMList)
2: i←1;
3: while VMList ≠ ɸ do
4: HostId ←RankingAlgo(HostList; Requirmenti; Rank);
5: HostHostId←VMi ;
6: i←i + 1;
7: end while
8: end procedure
1: procedure RankingAlgo (HostList; Requirment; Rank)
2: for each Host € HostList do
3: if Host Satisfies the Requirments then
4: add (MemberList;Host);
5: end if
6: end for
7: PriorityList← SortByRank(MemberList;Rank);
8: AllocatedHost←PriorityList(1);
9: Return AllocatedHost;
10: end procedure
|
|
|
|
|
There is nothing in there that requires anything more than a understanding for the java language (no API needed.)
So the idea is learn basic java and then write the code.
|
|
|
|
|
i want to create a java project:
Create objecte
create two function WriteXml () and ReadXml !
writeXml(): save informayion to xml file
ReadXml(): Read information frm xml file and show!
i use jdom 2.02
i do on 1 file "WriteReadXml.java"
-----code
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.jdom2.Document;
import org.jdom2.Element;
import org.jdom2.JDOMException;
import org.jdom2.Text;
import org.jdom2.input.SAXBuilder;
import org.jdom2.output.Format;
import org.jdom2.output.XMLOutputter;
public class ReadWriteXml {
public static void main (String[] args){
writeXml ();
}
private static void ReadXml(){
SAXBuilder builder = new SAXBuilder();
Document readDoc = null;
try {
readDoc = builder.build(new File("./src/jdomMade.xml"));
} catch (JDOMException | IOException e) {
e.printStackTrace();
}
System.out.println("Root:" + readDoc.getRootElement());
System.out.println("Show:"+
readDoc.getRootElement().getChild("show").getChildText("name"));
System.out.println("show ID :" + readDoc.getRootElement().getChild("show").getChild("name").getAttributeValue("show_id) + "));
Element root = readDoc.getRootElement();
for (Element curEle : root.getChildren("show"));{
Element curEle = null;
System.out.println("show Name : " +
curEle.getChildText("name"));
System.out.println("show ID : "
+curEle.getChild("name").getAttributeValue("show_id"));
System.out.println(" on " +
curEle.getChildText("network")+"in the");
System.out.println(curEle.getChild("network").getAttributeValue("country"));
}
}
private static void writeXml () {
try{
Document doc = new Document();
Element theRoot = new Element ("tvshows");
doc.setRootElement(theRoot);
Element show = new Element ("show");
Element name = new Element ("name");
name.setAttribute("show_id","shows_001");
name.addContent(new Text ("Game program"));
Element network = new Element ("network");
network.setAttribute("C***ry","TN");
network.addContent(new Text ("TNN"));
show.addContent(name);
show.addContent(network);
theRoot.addContent(show);
Element show2 = new Element ("show");
Element name2 = new Element ("name");
name2.setAttribute("show_id","shows_002");
name2.addContent(new Text ("Kids prgram"));
Element network2 = new Element ("network");
network2.setAttribute("C***ry","FR");
network2.addContent(new Text ("TNT"));
show2.addContent(name2);
show2.addContent(network2);
theRoot.addContent(show2);
XMLOutputter xmlOutput = new XMLOutputter (Format.getPrettyFormat());
xmlOutput.output(doc, new FileOutputStream(new File (".src/jdomMade.xml")));
System.out.println("Wrote to file");
}
catch (Exception ex){
ex.printStackTrace();
}
}
} ----
_________________________
error is :
at java.io.FileOutputStream.<init>(Unknown Source)
at java.io.FileOutputStream.<init>(Unknown Source)
at ReadWriteXml.writeXml(ReadWriteXml.java:84)
at ReadWriteXml.main(ReadWriteXml.java:16)
tnx for answer me http://s.codeproject.com/script/Forums/Images/thumbs_up.gif
http://s.codeproject.com/script/Forums/Images/smiley_doh.gif
|
|
|
|
|
Hello,
The problem is in following line
xmlOutput.output(doc, new FileOutputStream(new File (".src/jdomMade.xml")));
Please correct it to
xmlOutput.output(doc, new FileOutputStream(new File ("./src/jdomMade.xml")));
Without this you are probably going to get FileNotFoundException.
Regards,
Prasad P. Khandekar
Knowledge exists, man only discovers it.
|
|
|
|
|
A jsp project is developed by using Tomcat server.Now I want to install the same project in Jboss server. Can anyone tell me the steps to do????
My database is Microsoft SQL server 2008 R2
|
|
|
|
|
|
Hello Experts,
I have PDF files with tables.
I am required to extract text of the file and identify the tables.
I am using iTextPDF as my PDF parser. I receive the text in tables as strings.
Can someone suggest me a good approach for this?
Please help me.
Thanks
Raesa
|
|
|
|
|
What kind of "approach" are you thinking of?
Sounds like you've got the issue covered.
regards Torsten
I never finish anyth...
|
|
|
|
|
Hello Torsten,
I need to identify tables in PDF.
The text in a page comes like a single string. I am not sure how to go ahead with this.
I have to identify the table header and data in each row and column and i am not sure how to do this.
It would be nice if I could get some advice me on this.
Thanks
Raesa
|
|
|
|
|
Have you tested some? You might be able to identify the table in the stripped text by some special character( or combination).
regards Torsten
I never finish anyth...
|
|
|
|
|
I tried but it simply comes as text string with new line separator.
I am not sure how to go forward on this.
Raesa
|
|
|
|
|
hmm, then you're running into some problem.
PDF have no tables. It's text with some lines drawn around.
Please check if you can figure some additional spaces in the text, e.g. 3 spaces ( " " ) would be the place where a line of the table was placed.
If you cannot find anything like that and work with it, you would have to reject that ticket.
regards Torsten
I never finish anyth...
|
|
|
|
|
Hi Everyone,
I am working on applet automation. I am running applet in Internet Explorer and I an using java language for automation. How I get the applet control which run in browser using java or c#. I want to write a listener for Internet Explorer but I don't know how I write that. So please help me for applet automation in any language.
Thanks for help in advance.
|
|
|
|
|
|
Thanks for replying...
I want get the applet control ID and name which we can use for automation. I want automate applet as automating filling the value in text field and performing click event. I already done for java swing using java agent but I didn't find any solution for applet. Please give me a suitable direction. When I run the applet in applet viewer I can automate that one using the java agent. Problem is, if I run in browser then that is not AWT windows and I can not automate. How I get IE control using java language. How I write listener for IE window.
I want applet automation which run in browser using any language, but I am trying using java language.
thanks in advance...
|
|
|
|
|
I have a problem with constructors ... I never understood how they work.
At Caine c=new Caine();
Animal c1=new Caine();
Pisica p=new Pisica();
Error: Constructor Caine in Caine class cannot be applied to given class
package test2;
public class Test2 {
public static void main(String[] args) {
ListaAnimale lista= new ListaAnimale();
Caine c=new Caine();
Animal c1=new Caine();
Pisica p=new Pisica();
lista.adauga(c);
lista.adauga(p);
c.faceZgomot();
}
}
class ListaAnimale{
private Animal [] animale = new Animal[5];
private int index=0;
public void adauga(Animal a){
if(index <animale.length)
{
animale[index]=a;
System.out.println("Un nou animal pe pozitia " +index);
index++;
}
}
}
abstract class Animal{
private String nume;
private int varsta;
public Animal(String n, int a){
this.nume=n;
this.varsta=a;
}
public void faceZgomot(){System.out.println("ce zgomot face");}
public abstract void mananca();
public void doarme(){
System.out.println("Doaermee");
}
}
class Caine extends Animal{
public Caine(String n, int a){
super(n,a);
}
public void faceZgomot(){System.out.println("wooar");}
public void mananca(){System.out.println("caarne");}
}
class Pisica extends Animal{
public Pisica(String n, int a){
super(n,a);
}
public void faceZgomot(){System.out.println("miau");}
public void mananca(){System.out.println("lapte");}
}
|
|
|
|
|
Caine c=new Caine();
Animal c1=new Caine();
Pisica p=new Pisica();
Your constructors are demanding some values:
public Caine(String n, int a){
super(n,a);
}
so your main would initalize those as following:
Caine c=new Caine("String", 0);
Animal c1=new Caine("anotherString", 1);
Pisica p=new Pisica("oneMoreString", 2);
Constructors are not that complicated. it's just some OOP as in any other method that you write.
http://docs.oracle.com/javase/tutorial/java/javaOO/constructors.html[^]
regards Torsten
I never finish anyth...
|
|
|
|
|
At Caine c=new Caine();
Animal c1=new Caine();
Pisica p=new Pisica();
These 3 statements wont work. As you can see, your program does not have no-arg constructor. when you dont write any constructor, then compiler will include a default no-arg constructor.
If you are explicitly writing a constructor then default constructor wont be added. You have to write your own default no-arg constructor. Then the above lines will run successully.
Regards
Vipul
|
|
|
|
|
I am trying to get the font data(coordinate points) from some font file such as ttf, Is there a pre-defined mthod in java works same as pre-definedGetFontData function, where this function retrieves font metric data for a TrueType font
|
|
|
|
|
|
|
i have two executable file 1. s.exe and 2 p.exe. i want to create a single installer that will install all two exe in sequential. any body help please
|
|
|
|
|
What does this have to do with Java?
|
|
|
|
|
hai friends............
i want the source code to receive the string in java based mobile phone via bluetooth from computer............
pls help me friends.................
|
|
|
|
|
usic vicky wrote: i want the source code Then you need to write it yourself, or use Google to search for samples[^].
|
|
|
|