Package com.sun.squawk.microedition.io

Examples of com.sun.squawk.microedition.io.FileConnection


  public static String getFileContents(String filename) {
    String url = "file:///" + filename;
    String contents = "";
    try {
      FileConnection c = (FileConnection) Connector.open(url);
      BufferedReader buf = new BufferedReader(new InputStreamReader(c
          .openInputStream()));
      String line = "";
      while ((line = buf.readLine()) != null) {
        contents += line + "\n";
      }
      c.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return contents;
  }
View Full Code Here


  }

  public static void writeToFile(String filename, String contents) {
    String url = "file:///" + filename;
    try {
      FileConnection c = (FileConnection) Connector.open(url);
      OutputStreamWriter writer = new OutputStreamWriter(c
          .openOutputStream());
      writer.write(contents);
      c.close();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

     */
    private static String getFileContents(String filename) {
        String url = "file:///values/" + filename;
        String contents = "";
        try {
            FileConnection c = (FileConnection) Connector.open(url);
            BufferedReader buf = new BufferedReader(new InputStreamReader(c.openInputStream()));
            String line;

            boolean lineRead;
            while ((line = buf.readLine()) != null) {
                lineRead = false;
                if (line.charAt(0) != '#') {
                    for (int i = 0; i < line.toCharArray().length; i++) {
                        if (line.toCharArray()[i] == '#') {
                            contents += line.substring(0, i).trim() + "\n";
                            lineRead = true;
                            break;
                        }
                    }
                    if (lineRead == false) {
                        contents += line + "\n";
                    }
                }
            }
            c.close();
        }
        catch (IOException e) {
        }
        return contents;
    }
View Full Code Here

TOP

Related Classes of com.sun.squawk.microedition.io.FileConnection

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.