X-Git-Url: http://svarog.pmf.uns.ac.rs/gitweb/?p=pub%2Fdonny%2Fant-tasks.git;a=blobdiff_plain;f=next.java;fp=next.java;h=0000000000000000000000000000000000000000;hp=2153047d6b19a2f772dca161eb085ff90cf9e411;hb=6d35827c1c1eaa78f87fab44b39cd2beac1382b1;hpb=04adb28045b82c599ffd310f93f69d18b6d880a8 diff --git a/next.java b/next.java deleted file mode 100644 index 2153047..0000000 --- a/next.java +++ /dev/null @@ -1,106 +0,0 @@ -package svetovid; - -import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Task; - -import java.io.*; - -/** - * Na osnovu spiska i trenutnog studenta nadji sledeceg. - * cita se iz current.txt, a pise u taj i current.properties - * Ovo se onda korisiti za kopiranje fajlova u buildu - * (bio je task init) - */ -public class next extends Task { - private String student, group; - private String current; - private String file="studenti.txt"; - private String separator="\t"; - private String currentFilename="current.txt", - currentProperties="current.properties"; - - - private void setCurrent(String c) throws Exception{ - current = c; - if (current != null){ - String[] s = current.split(separator); - if (s.length<2) - throw new Exception("problem setting current student name - can't split group and name"); - student = s[1]; - group = s[0]; - } else { - student = null; - group = null; - } - } - - private void loadCurrent(){ - try{ - File f = new File(currentFilename); - if (f.exists()){ - BufferedReader r = new BufferedReader( - new InputStreamReader( - new FileInputStream(f))); - setCurrent(r.readLine()); - r.close(); - } else - setCurrent(null); - }catch (Exception ex) { - throw new BuildException(ex); - } - } - - private void saveCurrent(){ - try{ - PrintWriter w = new PrintWriter(new FileWriter(currentFilename)); - w.println(current); - w.close(); - }catch (Exception ex) { - throw new BuildException(ex); - } - //now the properties file - try{ - PrintWriter w = new PrintWriter(new FileWriter(currentProperties)); - w.println("student.group="+group); - w.println("student.current="+student); - w.close(); - }catch (Exception ex) { - throw new BuildException(ex); - } - } - - // The method executing the task - public void execute() throws BuildException { - loadCurrent(); - try{ - BufferedReader r = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - String s = r.readLine(); - if (current != null) { - while (s!=null && s.compareTo(current)!=0) - s= r.readLine(); - setCurrent(r.readLine()); - } else { - setCurrent(s); - } - r.close(); - }catch (Exception ex) { - throw new BuildException(ex); - } - saveCurrent(); - } - - public void setSeparator(String msg) { - this.separator = msg; - } - - public void setFile(String msg) { - this.file = msg; - } - - public void setCurrentFilename(String msg) { - this.currentFilename = msg; - } - public void setCurrentProperties(String msg) { - this.currentProperties = msg; - } -}