Java
Resource aus Jar lesen
InputReader input = getClass().getResourceAsStream("appl.properties"); BufferedReader reader = new BufferedReader(new InputStreamReader(input)); String line; while( (line = reader.readLine()) != null) doIt(line);
Reguläre Ausdrücke
Pattern rexpr = Pattern.compile("Name: (\\w+)");
Matcher matcher;
while( (line = reader.readLine()) != null){
if ( (matcher = rexpr.matcher(line)).find()){
name = matcher.group(1);
}
}
Klassen
public abstract class Widget {
public enum WidgetType { WT_UNDEF, WT_POINT, WT_POLYLINE, WT_TEXT, WT_IMAGE };
protected int x;
protected int y;
protected String color;
protected WidgetType type;
Widget(WidgetType type, int x, int y, String color){
this.x = x;
this.y = y;
this.type = type;
this.color = color;
}
public abstract void draw(Sheet sheet);
}
public class PointWidget extends Widget{
protected int size;
PointWidget(int x, int y, String color, int size){
super(WT_POINT, x, y, color);
this.size = size;
}
@Override
public void draw(Sheet sheet) {
// ...
}
}