Package net.rim.device.api.io

Examples of net.rim.device.api.io.LineReader


     *
     * @param MapData
     *            Location of file containing site information.
     */
    private void storeAllSites(final String MapData) {
        final LineReader lineReader =
                new LineReader(getClass().getResourceAsStream(MapData));
        byte[] line;

        // For sites
        _siteNames = new Vector();
        _sites = new Vector();
        String currentSiteName;

        for (;;) {
            try {
                line = lineReader.readLine();

                if (MapFieldDemoTokenizer.getString(line).equals("Site Name:")) {
                    // Initialize site variables.
                    currentSiteName =
                            MapFieldDemoTokenizer.getString(lineReader
                                    .readLine());
                    _siteNames.addElement(currentSiteName);
                    _currentSite =
                            new MapFieldDemoSite(MapData, currentSiteName, _map);
                    _map.addSite(_currentSite);
View Full Code Here


     *
     * @param MapData
     *            Location of file containing site information.
     */
    private void storeAllCampuses(final String MapData) {
        final LineReader lineReader =
                new LineReader(getClass().getResourceAsStream(MapData));
        byte[] line;

        // For campuses
        String campusName;
        _campuses = new Vector();
        _campusCoordinates = new Vector();

        for (;;) {
            try {
                line = lineReader.readLine();

                if (MapFieldDemoTokenizer.getString(line).equals(
                        "Campus Display Name:")) {
                    campusName =
                            MapFieldDemoTokenizer.getString(lineReader
                                    .readLine());

                    // Make sure that there are no duplicate campuses in vector.
                    if (!_campuses.contains(campusName)) {
                        _campuses.addElement(campusName);

                        // Adds the campus' location.
                        if (MapFieldDemoTokenizer.getString(
                                lineReader.readLine()).equals(
                                "Default Campus Location:")) {
                            _campusCoordinates.addElement(MapFieldDemoTokenizer
                                    .getCoordinates(lineReader.readLine()));
                        }
                    }
                }
            } catch (final EOFException eof) {
                // We've reached the end of the file.
View Full Code Here

     *
     * @param filePath
     *            The document that describes all the site's properties.
     */
    private void formatSite(final String filePath) {
        final LineReader lineReader =
                new LineReader(getClass().getResourceAsStream(filePath));

        byte[] line;

        try {
            for (;;) {
                line = lineReader.readLine();

                // Check for end of file.
                if (MapFieldDemoTokenizer.getString(line).equals("EOF")) {
                    break;
                } else {
                    if (MapFieldDemoTokenizer.getString(line).equals(
                            "Site Name:")) {

                        if (MapFieldDemoTokenizer.getString(
                                lineReader.readLine()).equals(_siteName)) {

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    "Is Stand-alone Site:")) {
                                _standAloneSite =
                                        MapFieldDemoTokenizer.getString(
                                                lineReader.readLine()).equals(
                                                "true");
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    "Campus Display Name:")) {
                                _campus =
                                        MapFieldDemoTokenizer
                                                .getString(lineReader
                                                        .readLine());
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    "Default Campus Location:")) {
                                lineReader.readLine();
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    "Street Number:")) {
                                _streetNumber =
                                        MapFieldDemoTokenizer.getInt(lineReader
                                                .readLine());
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    "Street Name:")) {
                                _streetName =
                                        MapFieldDemoTokenizer
                                                .getString(lineReader
                                                        .readLine());
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals("City:")) {
                                _city =
                                        MapFieldDemoTokenizer
                                                .getString(lineReader
                                                        .readLine());
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals("Province:")) {
                                _province =
                                        MapFieldDemoTokenizer
                                                .getString(lineReader
                                                        .readLine());
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals("Country:")) {
                                _country =
                                        MapFieldDemoTokenizer
                                                .getString(lineReader
                                                        .readLine());
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    "Site Number:")) { // N\A if not applicable.
                                line = lineReader.readLine();

                                if (!MapFieldDemoTokenizer.getString(line)
                                        .equals("N\\A")) {
                                    _siteNumber =
                                            MapFieldDemoTokenizer.getInt(line);
                                }
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    "Site Number Placement:")) {
                                // N\A if not applicable.
                                line = lineReader.readLine();

                                if (!MapFieldDemoTokenizer.getString(line)
                                        .equals("N\\A")) {
                                    _siteNumberPlacement =
                                            MapFieldDemoTokenizer
                                                    .getCoordinates(line);
                                }
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    "Number of Points:")) {
                                _numberOfPoints =
                                        MapFieldDemoTokenizer.getInt(lineReader
                                                .readLine());
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals("Shape:")) {
                                _shape = new Coordinates[_numberOfPoints];

                                for (int pointsCount = 0; pointsCount < _numberOfPoints; pointsCount++) {
                                    _shape[pointsCount] =
                                            MapFieldDemoTokenizer
                                                    .getCoordinates(lineReader
                                                            .readLine());
                                }
                            }

                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    "Highlightable Area:")) {
                                _highlightableArea = new Coordinates[4];

                                for (int pointsCount = 0; pointsCount < 4; pointsCount++) {
                                    _highlightableArea[pointsCount] =
                                            MapFieldDemoTokenizer
                                                    .getCoordinates(lineReader
                                                            .readLine());
                                }
                            }

                            break;
View Full Code Here

        // Get an input stream from the file.
        final InputStream stream =
                getClass().getResourceAsStream("/Data/CountryData.txt");

        if (stream != null) {
            final LineReader lineReader = new LineReader(stream);

            // We read data from input stream one line at a time until we
            // reach end of file. Each line is parsed to extract data used
            // to construct Country objects.
            for (;;) {
                try {
                    final String line = new String(lineReader.readLine());

                    // Parse the current line.
                    final int comma1 = line.indexOf(',');
                    final String country = line.substring(0, comma1);
                    final int comma2 = line.indexOf(',', comma1 + 1);
View Full Code Here

     * Displays the help dialog
     */
    private void displayHelp() {
        final InputStream stream =
                getClass().getResourceAsStream("/resource/help_core.txt");
        final LineReader lineReader = new LineReader(stream);
        final StringBuffer help = new StringBuffer();

        for (;;) {
            try {
                help.append(new String(lineReader.readLine()));
                help.append('\n');
            } catch (final EOFException eof) {
                // We've reached the end of the file
                break;
            } catch (final IOException ioe) {
View Full Code Here

     */
    private DemoStringTokenizer getStringTokenizer() {

        final InputStream stream =
                getClass().getResourceAsStream("/resources/blackberry.txt");
        final LineReader lineReader = new LineReader(stream);
        final StringBuffer buffer = new StringBuffer();

        while (true) {
            try {
                buffer.append(new String(lineReader.readLine()));
                buffer.append("\n");
            } catch (final EOFException eof) {
                // We've reached the end of the file
                break;
            } catch (final IOException ioe) {
View Full Code Here

     * Displays the help dialog
     */
    private void displayHelp() {
        final InputStream stream =
                getClass().getResourceAsStream("/resource/help_extended.txt");
        final LineReader lineReader = new LineReader(stream);
        final StringBuffer help = new StringBuffer();

        for (;;) {
            try {
                help.append(new String(lineReader.readLine()));
                help.append('\n');
            } catch (final EOFException eof) {
                // We've reached the end of the file
                break;
            } catch (final IOException ioe) {
View Full Code Here

     */
    public Path[] getPaths(final VG11 vg, final String file) {
        final Vector vector = new Vector();

        // Read data from file
        final LineReader lineReader =
                new LineReader(getClass().getResourceAsStream(file));

        for (;;) {
            try {
                final String pathString = new String(lineReader.readLine());

                final int vgPath = VGUtils.vgCreatePath(vg, pathString);

                if (vgPath != VG10.VG_INVALID_HANDLE) {
                    // Create the Path object
                    final Path path = new Path(vgPath);

                    int fillPaint;

                    final String fillString = new String(lineReader.readLine());

                    try {
                        // Create the colored fill value
                        fillPaint = VGUtils.vgCreateColorPaint(vg, fillString);
                    } catch (final IllegalArgumentException e) {
View Full Code Here

    public MapFieldDemoScreen() {
        super(Manager.NO_VERTICAL_SCROLL);
        Coordinates defaultLocation;

        // Reads data from file.
        final LineReader lineReader =
                new LineReader(getClass().getResourceAsStream("/MapsData.txt"));

        // Maps instance for screen.
        _map = new DemoMapField();

        storeAllSites("/MapsData.txt");
        storeAllCampuses("/MapsData.txt");

        // Look for the default site.
        try {
            for (;;) {
                if (MapFieldDemoTokenizer.getString(lineReader.readLine())
                        .equals("Default Campus:")) {
                    _currentCampus =
                            MapFieldDemoTokenizer.getString(lineReader
                                    .readLine());

                    // Find campus location.
                    for (;;) {
                        if (MapFieldDemoTokenizer.getString(
                                lineReader.readLine()).equals(
                                "Campus Display Name:")) {
                            if (MapFieldDemoTokenizer.getString(
                                    lineReader.readLine()).equals(
                                    _currentCampus)) {
                                if (MapFieldDemoTokenizer.getString(
                                        lineReader.readLine()).equals(
                                        "Default Campus Location:")) {
                                    defaultLocation =
                                            MapFieldDemoTokenizer
                                                    .getCoordinates(lineReader
                                                            .readLine());
                                    break;
                                }
                            }
                        }
View Full Code Here

  String convertStreamToString(InputStream is) throws IOException {
 
  if (is != null) {
    try {
      StringBuffer sb = new StringBuffer();
      LineReader reader = new LineReader(is);
           
        for(;;)
          {
            try
              {
                String line = new String(reader.readLine());
                sb.append(line);
              }
            catch(EOFException eof)
              {
                // We've reached the end of the file.
View Full Code Here

TOP

Related Classes of net.rim.device.api.io.LineReader

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.