Convert Text File to String in java
<p>i have a written a code to send a text file by converting it into string and sending it into a web service. Please can someone tell me other available methods for sending the string as stream to Web Service.</p>

<pre><code>public class MainActivity extends Activity {
    Button b1;
    String s;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        b1=(Button)findViewById(R.id.button1);
        b1.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                File upfile=new File("sdcard/text/testfile.txt");
                try {
                    FileInputStream fin=new FileInputStream(upfile);
                    byte[] buffer= new byte[(int)upfile.length()];
                    new DataInputStream(fin).readFully(buffer);
                    fin.close();
                    s=new String(buffer,"UTF-8");
                    System.out.print(buffer);
                } catch (FileNotFoundException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
                // TODO Auto-generated method stub
                Toast.makeText(MainActivity.this, s, 20).show();

            }
        });
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }

}
</code></pre>
