Click here to Skip to main content
15,923,197 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I can see my text file in textview but i want to print in same manner as in file which is not seeing me on screen ...
my code to see file is

try {
Resources res = getResources();
InputStream in_s = res.openRawResource(R.raw.report);

byte[] b = new byte[in_s.available()];
in_s.read(b);
read.setText(new String(b));
} catch (Exception e) {
// e.printStackTrace();
//this is textview set text file view
read.setText("Error: can't show help.");
Posted
Comments
AndroidVivek 21-Nov-12 2:20am    
Is there any text file reader support?
can we make it ?
or any other option to show file?

1 solution

// try opening the myfilename.txt
  try {
    // open the file for reading
    InputStream instream = openFileInput("myfilename.txt");
 
    // if file the available for reading
    if (instream) {
      // prepare the file for reading
      InputStreamReader inputreader = new InputStreamReader(instream);
      BufferedReader buffreader = new BufferedReader(inputreader);
                 
      String line;
 
      // read every line of the file into the line-variable, on line at the time
      while (( line = buffreader.readLine())) {
        // do something with the settings from the file
      }
 
    }
     
    // close the file again       
    instream.close();
  } catch (java.io.FileNotFoundException e) {
    // do something if the myfilename.txt does not exits
  }
 
Share this answer
 
Comments
AndroidVivek 21-Nov-12 5:23am    
okay my code is also working , just i set layout its done....

now problem is in coming when i am printing ...the printing format is not coming proper...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900