Package java.io

Examples of java.io.BufferedReader


        invoke(m, this, new Object[0]);
        return true;
    }

    private void runShell() {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String last = "", line;
        System.out.println("Shell mode. Type the target, then [Enter]. Just [Enter] repeats the last target.");
        while (true) {
            System.out.print("build> ");
            try {
                line = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            if (line == null || line.equals("exit") || line.equals("quit")) {
                break;
View Full Code Here


    }
    if (tokens > 0) out.write('\n');
  }
 
  public static void open(HexModel dst, Reader in) throws IOException {
    HexReader reader = new HexReader(new BufferedReader(in));
    long offs = dst.getFirstOffset();
    while (reader.hasNext()) {
      int[] values = reader.next();
      if (offs + values.length - 1 > dst.getLastOffset()) {
        throw new IOException(Strings.get("hexFileSizeError"));
View Full Code Here

    }
    dst.fill(offs, dst.getLastOffset() - offs + 1, 0);
  }
 
  public static int[] parse(Reader in) throws IOException {
    HexReader reader = new HexReader(new BufferedReader(in));
    int cur = 0;
    int[] data = new int[4096];
    while (reader.hasNext()) {
      int[] values = reader.next();
      if (cur + values.length > data.length) {
View Full Code Here

    }
    return data;
  }

  public static void open(HexModel dst, File src) throws IOException {
    BufferedReader in;
    try {
      in = new BufferedReader(new FileReader(src));
    } catch (IOException e) {
      throw new IOException(Strings.get("hexFileOpenError"));
    }
    try {
      String header = in.readLine();
      if (!header.equals(RAW_IMAGE_HEADER)) {
        throw new IOException(Strings.get("hexHeaderFormatError"));
      }
      open(dst, in);
      try {
        BufferedReader oldIn = in;
        in = null;
        oldIn.close();
      } catch (IOException e) {
        throw new IOException(Strings.get("hexFileReadError"));
      }
    } finally {
      try {
View Full Code Here

                reply(421, "Too many users");
            } else {
                reply(220, SERVER_NAME);
                // TODO need option to configure the serverIpAddress?
                serverIpAddress = control.getLocalAddress().getHostAddress().replace('.', ',');
                BufferedReader input = new BufferedReader(new InputStreamReader(control.getInputStream()));
                while (!stop) {
                    String command = null;
                    try {
                        command = input.readLine();
                    } catch (IOException e) {
                        // ignore
                    }
                    if (command == null) {
                        break;
View Full Code Here

    private void connect(String url) throws IOException {
        socket = NetUtils.createSocket(url, 21, false);
        InputStream in = socket.getInputStream();
        OutputStream out = socket.getOutputStream();
        reader = new BufferedReader(new InputStreamReader(in));
        writer = new PrintWriter(new OutputStreamWriter(out, Constants.UTF8));
        readCode(220);
    }
View Full Code Here

        println("");
        println("Welcome to H2 File Shell " + Constants.getFullVersion());
        println("Exit with Ctrl+C");
        showHelp();
        if (reader == null) {
            reader = new BufferedReader(new InputStreamReader(in));
        }
        println(IOUtils.getCanonicalPath(currentWorkingDirectory));
        while (true) {
            try {
                print("> ");
View Full Code Here

    StreamUtilities.inputStream(new URL(urlString.toString()), new InputStreamProcessor() {

      @Override
      public void process(InputStream inputStream) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, "UTF8"));

        int countProgram = 0;
        String line;
        String lastLine = "";
        while ((line = reader.readLine()) != null) {
          if (lastLine.length() > 0) { // re-append updated descriptions.
            line = lastLine + " " + line;
          }
          String[] items = line.trim().split("~");
View Full Code Here

      ArrayList<Channel> channels = new ArrayList<Channel>();

      monitor.setMessage(mLocalizer.msg("loadingChannels", "Loading Radio Times Channel List"));

      // Do the parsing...
      BufferedReader reader = new BufferedReader(new InputStreamReader(IOUtilities.getStream(new URL(BASEURL + "channels.dat"))));

      String line;

      while ((line = reader.readLine()) != null) {
        String[] channel = line.split("\\|");

        // format of a line in this file:
        // 92|BBC1
        if (channel.length == 2) {
          String channelId = channel[0].trim();
          String fullChannelId = RADIOTIMES + channelId;
          String channelName = channel[1].trim();
          int categories = Channel.CATEGORY_NONE;
          if (StringUtils.containsIgnoreCase(channelName, "TV") || StringUtils.containsIgnoreCase(channelName, "HD")) {
            categories = Channel.CATEGORY_TV;
          }
          Channel ch = null;
          // try to find this channel in the known channels so we can reuse its user settings
          for (Channel knownChannel : mChannels) {
            if (knownChannel.getId().equals(fullChannelId) && knownChannel.getDefaultName().equalsIgnoreCase(channelName)) {
              ch = knownChannel;
              break;
            }
          }
          if (ch == null) {
            ch = new Channel(this, channelName, fullChannelId, TimeZone.getTimeZone("GMT+0:00"), "gb",
                "(c) Radio Times", "http://www.radiotimes.co.uk", mRadioTimesChannelGroup, null, categories);
          }
          channels.add(ch);
          mLog.fine("Channel : " + ch.getName() + "{" + ch.getId() + "}");
        }

      }

      reader.close();

      mChannels = channels;

      monitor.setMessage(mLocalizer.msg("done", "Done with Radio Times data"));
View Full Code Here

        String insertStartMarker =
            Localizer.getMessage("jspc.webinc.insertStart");
        String insertEndMarker =
            Localizer.getMessage("jspc.webinc.insertEnd");

        BufferedReader reader = new BufferedReader(new FileReader(webXml));
        BufferedReader fragmentReader =
            new BufferedReader(new FileReader(webxmlFile));
        PrintWriter writer = new PrintWriter(new FileWriter(webXml2));

        // Insert the <servlet> and <servlet-mapping> declarations
        int pos = -1;
        String line = null;
        while (true) {
            line = reader.readLine();
            if (line == null) {
                break;
            }
            // Skip anything previously generated by JSPC
            if (line.indexOf(insertStartMarker) >= 0) {
                while (true) {
                    line = reader.readLine();
                    if (line == null) {
                        return;
                    }
                    if (line.indexOf(insertEndMarker) >= 0) {
                        line = reader.readLine();
                        line = reader.readLine();
                        if (line == null) {
                            return;
                        }
                        break;
                    }
                }
            }
            for (int i = 0; i < insertBefore.length; i++) {
                pos = line.indexOf(insertBefore[i]);
                if (pos >= 0)
                    break;
            }
            if (pos >= 0) {
                writer.print(line.substring(0, pos));
                break;
            } else {
                writer.println(line);
            }
        }

        writer.println(insertStartMarker);
        while (true) {
            String line2 = fragmentReader.readLine();
            if (line2 == null) {
                writer.println();
                break;
            }
            writer.println(line2);
        }
        writer.println(insertEndMarker);
        writer.println();

        for (int i = 0; i < pos; i++) {
            writer.print(" ");
        }
        writer.println(line.substring(pos));

        while (true) {
            line = reader.readLine();
            if (line == null) {
                break;
            }
            writer.println(line);
        }
        writer.close();

        reader.close();
        fragmentReader.close();

        FileInputStream fis = new FileInputStream(webXml2);
        FileOutputStream fos = new FileOutputStream(webXml);

        byte buf[] = new byte[512];
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.