![]() |
Read String in File text. fconn = (FileConnection) Connector.open("file:///D:/IP.txt", Connector.READ); in "file:///D:/IP.txt" have String "LocalHost" How to read string and show message "LocalHost" in my app please, |
Re: Read String in File text. Call FileConnection.openInputStream() to obtain a stream, then read the stream. |
Re: Read String in File text. Like in the earlier reply, once you have the connection, you could get the InputStream. You can then use the IOUtilities class provided by RIM to read the whole content into an array. InputStream in = fconn.openInputStream(); byte[] data = IOUtilities.streamToBytes( in ); You could then set the data in a StringBuffer, StringBuffer sb = new StringBuffer(data.length); sb.append(data); For small data file this would be an easier way to go. |
Re: Read String in File text. Quote:
|
Re: Read String in File text. Quote:
fconn = (FileConnection) Connector.open("file:///D:/IP.txt", Connector.READ); //is = fconn.openDataInputStream(); // data = IOUtilities.streamToBytes(is); InputStream in = fconn.openInputStream(); byte[] data = IOUtilities.streamToBytes(in); String sss = new String(data); oxi = new LabelField(sss); } catch (IOException e) { System.out.println(e.getMessage()); } add(oxi); Build Complete but....In my App is Error ! Helpme please |
Re: Read String in File text. Quote:
|
Re: Read String in File text. it shows debug source code is not available source code is not available source code is not available source code is not available source code is not available File system error (1003) when i click in my app |
Re: Read String in File text. Quote:
|
Re: Read String in File text. Can you Give me a sample code for read string in my Text file please :cry: |
Re: Read String in File text. Quote:
--------------------------------------------------------- public String readFile() { FileConnection fc = null; String fileContent = ""; try { fc = (FileConnection)Connector.open("file:///store/home/user/temp.txt"); if ( (fc==null) || !fc.exists()){ return "File does not exist"; } InputStream in = fc.openInputStream(); byte[] data = IOUtilities.streamToBytes( in ); fileContent = new String(data); in.close(); fc.close(); } catch (Throwable t) { } return fileContent; } |
Re: Read String in File text. here this code class Connect extends MainScreen { Connect() { FileConnection fc = null; String fileContent = ""; try { fc = (FileConnection)Connector.open("file:///D:/IP.txt"); if ( (fc==null) || !fc.exists()){ return "File does not exist"; } InputStream in = fc.openInputStream(); byte[] data = IOUtilities.streamToBytes(in); fileContent = new String(data); in.close(); fc.close(); } catch (Throwable t) { } return fileContent; } } it error " cannot return a value from method whose result type is void " where is a void i don't declare a void function |
Re: Read String in File text. Quote:
String Connect() { //instead of Connect() { |
Re: Read String in File text. Well, actually, constructors can't return a value at all. |
Re: Read String in File text. Quote:
|
Re: Read String in File text. Quote:
|
Re: Read String in File text. In netbean i'm use Class Scanner for read string but In Blackberry Jde not have class Scanner |
Re: Read String in File text. Quote:
|
| All times are GMT -5. The time now is 04:00 AM. |
Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.