iNettuts

http://nettuts.s3.amazonaws.com/127_iNETTUTS/demo/index.html

<script type=”text/javascript” src=”http://jqueryjs.googlecode.com/files/jquery-1.2.6.min.js”></script>
<script type=”text/javascript” src=”jquery-ui-personalized-1.6rc2.min.js”></script>
<script type=”text/javascript” src=”inettuts.js”></script>

<li class=”widget color-green” id=”intro”>
<div class=”widget-head”>
<h3>Welcome to iNettuts</h3>
</div>
<div class=”widget-content”>
<p>Hello, welcome to the <strong>iNettuts</strong> demonstration. The tutorial which details how this interface was created can be found on <a href=”http://nettuts.com”>NETTUTS.com</a>.</p>
<p>This demo and its accompanying tutorial were made by <a href=”http://james.padolsey.com”>James Padolsey</a>.</p>
<p>NOTE: You’ll notice that you cannot move, edit, remove or collapse this particular widget – the script which this is running on allows for per-widget settings and this widget has been set not to allow closing, editing, collapsing or moving.</p>
</div>
</li>

Tutorial : XML generation with JAVA

http://javazoom.net/services/newsletter/xmlgeneration.html

(5) – JAXP + SAX + Serialization to servlet output stream : JDK 1.4 compliant –

import java.io.*;
// SAX classes.
import org.xml.sax.*;
import org.xml.sax.helpers.*;
//JAXP 1.1
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;
import javax.xml.transform.sax.*;
[...]
// PrintWriter from a Servlet
PrintWriter out = response.getWriter();
StreamResult streamResult = new StreamResult(out);
SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
// SAX2.0 ContentHandler.
TransformerHandler hd = tf.newTransformerHandler();
Transformer serializer = hd.getTransformer();
serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");
serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd");
serializer.setOutputProperty(OutputKeys.INDENT,"yes");
hd.setResult(streamResult);
hd.startDocument();
AttributesImpl atts = new AttributesImpl();
// USERS tag.
hd.startElement("","","USERS",atts);
// USER tags.
String[] id = {"PWD122","MX787","A4Q45"};
String[] type = {"customer","manager","employee"};
String[] desc = {"Tim@Home","Jack&Moud","John D'oé"};
for (int i=0;i {
atts.clear();
atts.addAttribute("","","ID","CDATA",id[i]);
atts.addAttribute("","","TYPE","CDATA",type[i]);
hd.startElement("","","USER",atts);
hd.characters(desc[i].toCharArray(),0,desc[i].length());
hd.endElement("","","USER");
}
hd.endElement("","","USERS");
hd.endDocument();
[...]

throw

throw new UnsupportedOperationException(“Not supported yet.”);

How to start this damn servlet on the damn Tomcat!

How-to: Eclipse and Tomcat
In this tutorial you will learn how to setup a Sun JSF RI 1.2 (Mojarra) playground with Eclipse 3.3 (Europa/Ganymede) and Apache Tomcat 6.0 (Catalina). A JSF 1.2 environment requires at least the Java 5.0, JSP 2.1 and Servlet 2.5 API’s. We’ll download and install Java SE 6 SDK, Eclipse 3.3 IDE (with WTP for Java EE development) and Tomcat 6.0 Application server (which supports JSP 2.1 and Servlet 2.5 API’s). Additionally we’ll also download and install JSTL 1.2 which can be used in combination with JSF, thanks to unified EL.

http://balusc.blogspot.com/2008/01/jsf-tutorial-with-eclipse-and-tomcat.html

loading images into memory and converting into array

Step 1: Creating java.awt.Image associated with file.

public void LoadFile(String path) {
		Image LI = Toolkit.getDefaultToolkit().createImage(path);
		GrubImage(Image2BufferedImage(LI));
	};

Step 2: Loading the image into java.awt.image.BufferedImage.
Read the rest of this entry »

string parsing

int addOK(String s) converts string s to array of double d and puts this into vector v.

String example:
s=”0.75000E-01 0.12628E-02 0.60278E+3 0.26278E-12 0.27898E-10 0.57278E-42 0.28928E+04″

The s must include exactly 7 componens.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import java.util.StringTokenizer;
import java.util.Vector;
 
 
public class DataBlock {
	int numer=0;
	public String Name;
	public String Description="";
	Vector v=null;
	//public String Name;
 
	DataBlock(String n){
		this.Name=n;
		this.v=new Vector(161);
	}
 
	public int len(){
		return v.size();
	}
 
	int addOK(String s){
 
			double[] d=new double[7];
			StringTokenizer st = new StringTokenizer(s);
 
			int i=0;
 
			while (st.hasMoreTokens()) {
	               String token = st.nextToken();
	               char c = token.charAt(0);
	               if( c  '9' )
	                   return 0;
	               else {
 
	            	   token=test(token);
	            	   d[i]=Double.parseDouble(token);
	                   i++;
	               }
	           }
 
			if(i!=7){
			System.out.println("Wrong file!");
			return 2;}
 
			v.add(d);
			return 1;
	}
 
	private String test(String t) {
		int k=findPM(t);
		if (t.charAt(k-1)!='E'){
			return t.substring(0, k)+"E"+t.substring(k,t.length());}
		//0.26278E-12 0.262783-126
		return t;
	}
 
	private int findPM(String t) {
		int l=t.length();
		char c;
		for(int i=0;i&lt;l;i++)
		{
			c=t.charAt(l-1-i);
			if((c=='+')|(c=='-')){return (l-1-i);}
		}
		// TODO Auto-generated method stub
		return 0;
	}
 
	public double[] readDBlock(int i){
		return this.v.get(i);
	}
 
 
 
 
}

calling console exe programs from a GUI

http://forum.vingrad.ru/forum/topic-202405/kw-c++-вызов.html

24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
private void button1_Click(object sender, EventArgs e)
{
 
Process p = new Process();
String pp = "";
 
if (this.radioButton1.Checked) 
{ pp = "Polinom_3.0_3ver.exe"; }
if (this.radioButton2.Checked) 
{ pp = "Polinom_DifWeights_3.0_3ver.exe"; }
if (this.radioButton3.Checked) 
{ pp = "PolinomDiametr2.0.exe"; }
if (this.radioButton4.Checked) 
{ pp = "PolinomDiametr_2.0_DifWeights.exe"; }
 
 
String fp = Environment.CurrentDirectory;
 
p.StartInfo.FileName = fp+"\\"+pp;
p.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
 
p.Start(); 
 
//----------------------------------------------------
 
String inf = this.textBox1.Text; 
 
 
inf = Environment.CurrentDirectory + "\\data.txt";
StreamReader re = File.OpenText(inf);
String input = null;
 
listBox1.BeginUpdate();
listBox1.Items.Clear(); 
while ((input = re.ReadLine()) != null)
{
listBox1.Items.Add(input);  
}
listBox1.EndUpdate();
}

test

1
2
3
4
5
public class Hello {
  public static void main(String[] args) {
    System.out.println("Hello World!");
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
package rebecca.e9.standart.pipes;
import rebecca.e9.core.*;
 
public class EmptyPipe  extends Pipe {
 
public EmptyPipe() {
super("Do nothing.");
}
 
public void Execute() {
 
}
 
public void Init() {
}
 
public void ShutDown() {
}
}
   Newer→