Package java.io

Examples of java.io.BufferedReader


      throw new IllegalArgumentException("Conversion from String to "+ type.getName() + " is not supported"); //$NON-NLS-1$ //$NON-NLS-2$
    }

  public static String[] getLines(final String value) {
      StringReader stringReader = new StringReader(value);
      BufferedReader reader = new BufferedReader(stringReader);
      ArrayList result = new ArrayList();
      try {
          String line = reader.readLine();
          while (line != null) {
              result.add(line);
              line = reader.readLine();
          }
      } catch (IOException e) {
          throw new TeiidRuntimeException(e);
      }
      return (String[]) result.toArray(new String[result.size()]);
View Full Code Here


    }
    return folder;
  }
 
  public static void copyWithVariableSubstitution(File source, File target, Map<String,String> variables, String varPrefix, String varSuffix) throws IOException {
    BufferedReader reader = null;
    BufferedWriter writer = null;
    try {
      reader = new BufferedReader(new InputStreamReader(new FileInputStream(source)));
      writer = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(target)));
      String line = reader.readLine();
      while (line != null) {
        line = substitute(line, variables, varPrefix, varSuffix);
        writer.write(line + "\n");
        line = reader.readLine();
      }
    } catch (IOException e) {
      throw e;
    } finally {
      if (writer != null) {
        try {
          writer.close();   
        } catch (IOException e) {         
        }
      }
      if (reader != null) {
        try {
          reader.close();
        } catch (IOException e) {         
        }
      }
    }
  }
View Full Code Here

    if (getMetadataFile(tmlFile).exists()) {
      TMLFileMetadataModel metaDataFile = new TMLFileMetadataModel(tmlFile);
      metaData.setDirectAccess(metaDataFile.isDirectAccess());
    }

    BufferedReader reader = null;
    try {
      reader = new BufferedReader(new InputStreamReader(tmlFile.getContents()));
      String readLine = null;
      readLine = reader.readLine();
      while (readLine != null && readLine.startsWith("##MDSET ")) {
        try {
        metaData.processDesignHeader(readLine);
                }
                catch (Exception e) {
                    Activator.getDefault().logError("Unable to process design metadata header '" + readLine + "' in file '" + tmlFile.getLocation().toString() + "'.", e);
                }
        readLine = reader.readLine();
      }

    } catch (CoreException e) {
    } catch (IOException e) {
    } finally {
      if (reader != null) {
        try {
          reader.close();
        } catch (IOException e) {         
        }
      }
    }
View Full Code Here

    if (is != null) {
      StringBuilder sb = new StringBuilder();
      String line;

      try {
        BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
        while ((line = reader.readLine()) != null) {
          sb.append(line).append("\n");
        }
      } finally {
        is.close();
      }
View Full Code Here

    }
    case UNKNOWN:  //assume a document
    case DOCUMENT: //filter the doc declaration
      XMLInputFactory inputFactory = XMLInputFactory.newInstance();
      if (!(r instanceof BufferedReader)) {
        r = new BufferedReader(r);
      }
      XMLEventReader eventReader = inputFactory.createXMLEventReader(r);
      eventReader = inputFactory.createFilteredReader(eventReader, new EventFilter() {
        @Override
        public boolean accept(XMLEvent event) {
View Full Code Here

        m_format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        m_format.setCalendar(calendar);
*/        try {
           
            // load the earthquake database
            BufferedReader rrdr = new BufferedReader
                (new InputStreamReader(QuakeBase.class.
                getResourceAsStream("/regions.txt")));
            readRegions(rrdr);
            BufferedReader qrdr =
                new BufferedReader(new InputStreamReader(QuakeBase.class.
                getResourceAsStream("/fulldata.txt")));
            readQuakes(qrdr);
            for (int i = 0; i < m_seismicInfos.length; i++) {
                m_seismicInfos[i].fix();
            }
View Full Code Here

  }

  public void run() {
    bContinue = true;
    while (bContinue) {
      BufferedReader br = null;
      try {
        Socket sck = socket.accept();
        String address = sck.getInetAddress().getHostAddress();
        if (address.equals("localhost") || address.equals("127.0.0.1")) {
          br = new BufferedReader(new InputStreamReader(sck.getInputStream()));
          String line = br.readLine();
          //System.out.println("received : " + line);
          if (line != null) {
            //            main.showMainWindow();
            StringTokenizer st = new StringTokenizer(line, ";");
            List argsList = new ArrayList();
            while( st.hasMoreElements() )
              argsList.add(st.nextToken().replaceAll("&;", ";").replaceAll("&&", "&"));
            if (argsList.size() > 1 )
            {
              String checker = (String) argsList.remove(0);
              if (checker.equals(AzureusCoreSingleInstanceClient.ACCESS_STRING)) {
                if (argsList.get(0).equals("args")) {
                  argsList.remove(0);                 
                  String newargs[] = new String[argsList.size()];
                  argsList.toArray(newargs);
                  Main.processArgs(newargs, null, null);
                } else {
                  Logger.getLogger("azureus2").error("Something strange was sent to the StartServer: " + line);
                }
              } else {
        Logger.getLogger("azureus2").error("StartServer: Wrong access token.");
              }
            }
          }
        }
        sck.close();

      } catch (Exception e) {
        if (!(e instanceof SocketException))
          e.printStackTrace();
        bContinue = false;
      } finally {
        try {
          if (br != null)
            br.close();
        } catch (Exception e) {
        }
      }
    }
  }
View Full Code Here

  {
    if( userManager == null )
      return UserProfile.DEFAULT_USER_PROFILE;
   
    PrintStream ps = new PrintStream(out);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    ps.print("Username: ");
    String username = br.readLine();
    ps.print("Password: ");
    String password = br.readLine();
    UserProfile userProfile = userManager.authenticate(username, password);
    if( userProfile != null )
    {
      ps.println("Login successful");
      return userProfile;
View Full Code Here

    addParam(String.valueOf(data.length));

    headers = new Hashtable();
    body = new StringBuffer();

    BufferedReader rd = new BufferedReader(new StringReader(new String(data)));

    try
    {
      // extract the MIME headers
      String line = rd.readLine();
      while(line != null && !line.equals(""))
      {
        int index = line.indexOf(':');
        if(index != -1)
          headers.put(line.substring(0, index).trim(), line.substring(index + 1).trim());
        line = rd.readLine();
      }

      // the rest is the body part
      int count;
      do
      {
        char[] buf = new char[100];
        count = rd.read(buf, 0, 100);
        if(count != -1)
          body.append(buf, 0, count);
      } while(count != -1);
    }
    catch(IOException e)
View Full Code Here

   */
  public void run()
  {
    try
    {
      BufferedReader rd = new BufferedReader(
          new InputStreamReader(conn.getInputStream(), "UTF-8"));
      Logger logger = LogManager.getLogger();

      while(!stop)
      {
View Full Code Here

TOP

Related Classes of java.io.BufferedReader

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.