import java.net.*;
import java.io.*;

public class FileServerClient
{
   public String write (String filename, String item)
   {
      return doit(filename+":writ:"+item);
   }

   public String read (String filename, int rec)
   {
      return doit(filename+":read:"+String.valueOf(rec));
   }

   public String create (String filename)
   {
      return doit(filename+":crea");
   }

   private String doit (String sendstr)
   {
      String server = new String("http://129.137.10.27/cgi-bin/fileserver?");
      URL s;
      try
      {
	 s = new URL(server+sendstr);
         DataInputStream in = new DataInputStream(s.openStream());
         String out=in.readLine();
         if (out.equals("-1") || out.equals("-2"))
            return new String ("");
         else
            return out;         
      }
      catch(IOException e)
      {
         System.out.println("Error: "+String.valueOf(e));
         return new String("");
      }
   }
}