Tuesday, November 2, 2010

Monday, November 1, 2010

Using Java to modify CSS

I'm not a CSS expert, as you might see the search field on this blog has just moved a few pixels down: the shoemaker's son always goes barefoot

Actually I'm doing some stuff related to a tour of polish rock band Buldog.

I cannot find an option in Photoshop to save sliced image in the way I like.

Of course I can do in manually, but with so many divs and many further changes I should automate it somehow :)

Code listing:

public class changeCSS {
public static void main(String[] args) {
try {
ArrayList fileNames = new ArrayList();

for (String fileName : fileNames) {
File file = new File(fileName);
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(file)));

String line = null;
StringBuffer sb = new StringBuffer();

while ((line = br.readLine()) != null) {

if (line.startsWith("#poland-background-PSD-div-")) {
int offset = line.indexOf("div-");
String number = line.substring(offset+4, offset+6);
sb.append("\tbackground: url(images/poland-background_PSD_div_" + number + ".png);\n");

} catch (Exception e) {

And some excel as well, it's quick enough and automate anough for me: