Package java.io

Examples of java.io.IOException


          (! line.trim().equals("")) &&
          (! line.startsWith("#"))) {
        StringTokenizer st = new StringTokenizer(line);
        // did we get 2 tokens ?
        if (st.countTokens() != 2) {
          throw new IOException("line "+lineno+" don't consists of 2 fields");
        }

        String allowStr = st.nextToken();
        boolean allow = true;
        String expression = st.nextToken();

        // allow or deny ?
        if (allowStr.equalsIgnoreCase("allow")) {
          allow=true;
        } else if (allowStr.equalsIgnoreCase("deny")) {
          allow=false;
        } else {
          throw new IOException("first token in line "+lineno+
          " has to be allow or deny");
        }

        addRule(expression,allow);
      }
View Full Code Here


    (! line.trim().equals("")) &&
    (! line.startsWith("#"))) {
  StringTokenizer st = new StringTokenizer(line);
  // we need at least 2 tokens
  if (st.countTokens() < 2) {
    throw new IOException("line "+lineno+" has less then 2 fields");
  }

  String allowStr = st.nextToken();
  boolean allow = true;
  String mime = st.nextToken();

  // allow or deny ?
  if (allowStr.equalsIgnoreCase("allow")) {
    allow=true;
  } else if (allowStr.equalsIgnoreCase("deny")) {
    allow=false;
  } else {
    throw new IOException("first token in line "+lineno+
        " has to be allow or deny");
  }
   
 
  DownloadRule r = new DownloadRule();
  r.setAllow(allow);
  try {
    r.setMimeType(mime);
  } catch (IllegalArgumentException e) {
    throw new IOException(e.getMessage());
  }
 

  // parse < and > rules
  while (st.hasMoreTokens()) {
    boolean isMin=true;

    String descr=st.nextToken();
   
    if (descr.startsWith("<")) {
      // it is a maximum value
      isMin=false;
    } else if (descr.startsWith(">")) {
      isMin=true;
    } else {
      throw new IOException("can't understand "+descr+
          " in line "+lineno);
    }

    int size=0;
    try {
      size = Integer.parseInt(descr.substring(1));
    } catch (NumberFormatException e) {
      throw new IOException("no numerical value "+descr+
          " in line "+lineno);
    }

    if (isMin) {
      r.setMinSize(size);
View Full Code Here

    }

    try {
      chunkCount = Integer.parseInt(line.trim(),16);
    } catch (NumberFormatException e) {
      throw new IOException("malformed chunk ("+line+")");
    }
    contentLength += chunkCount;
    if ( chunkCount == 0 ) {
      readFooters();
    }
View Full Code Here

        }

        //
        // Password not found
        //
        throw new IOException();
    }
View Full Code Here

        }
       
        //
        // Password not found
        //
        throw new IOException();
    }
View Full Code Here

           
            try {
                client.validateTransfer();
            }
            catch (FTPException ex) {
                throw new IOException(ex.getMessage());
            }
           
            if (monitorEx != null)
                monitorEx.transferComplete(TransferDirection.DOWNLOAD, remoteFile);
        }
View Full Code Here

    HttpConnection connection = new HttpConnection();
    try {
      connection.socket = TimedSocket.getSocket(address, port, timeout);
      connection.socket.setSoTimeout(timeout);
    } catch (InterruptedIOException e) {
      throw new IOException("timeout during connect: "+e.getMessage());
    }
    return connection;
  }
View Full Code Here

   *
   * @return an InputStream or null if no connection is established
   * @exception IOException if an I/O error occurs when creating the stream
   */
  public InputStream getInputStream() throws IOException {
    if (socket == null) throw new IOException("not conected");
    return socket.getInputStream();
  }
View Full Code Here

   *
   * @return an OutputStream or null if no connection is established
   * @exception IOException if an I/O error occurs when creating the stream
   */
  public OutputStream getOutputStream() throws IOException {
    if (socket == null) throw new IOException("not conected");
    return socket.getOutputStream();
  }
View Full Code Here

      int writeMode = getWriteMode();
      Instances structure = getInstances();
      PrintWriter outW = null;
     
      if(getRetrieval() == BATCH || getRetrieval() == NONE)
          throw new IOException("Batch and incremental saving cannot be mixed.");
      if(getWriter() != null)
          outW = new PrintWriter(getWriter());
         
      if(writeMode == WAIT){
        if(structure == null){
            setWriteMode(CANCEL);
            if(inst != null)
                System.err.println("Structure(Header Information) has to be set in advance");
        }
        else
            setWriteMode(STRUCTURE_READY);
        writeMode = getWriteMode();
      }
      if(writeMode == CANCEL){
          if(outW != null)
              outW.close();
          cancel();
      }
      if(writeMode == STRUCTURE_READY){
          setWriteMode(WRITE);
          //write header
          Instances header = new Instances(structure,0);
          if(retrieveFile() == null || outW == null)
              System.out.println(header.toString());
          else{
              outW.print(header.toString());
              outW.print("\n");
              outW.flush();
          }
          writeMode = getWriteMode();
      }
      if(writeMode == WRITE){
          if(structure == null)
              throw new IOException("No instances information available.");
          if(inst != null){
          //write instance
              if(retrieveFile() == null || outW == null)
                System.out.println(inst);
              else{
View Full Code Here

TOP

Related Classes of java.io.IOException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.