title: upload file using http put -T in android?
body: <p><br>
     I have an android class which use http put to call REST web service . But it create empty folder no content how do i do? 
  when i test web service using curl command it works and can upload successfully.</p>
  
  <p>curl -v -T C:\downloads\a.jpg -H "Content-Type:application/vnd.org.snia.cdmi.dataobject" <a href="http://192.168.37.241:8080/kyaw/ktest/a.jpg" rel="nofollow">http://192.168.37.241:8080/kyaw/ktest/a.jpg</a> </p>
  
  <p>public class putandroid extends Activity {</p>
  
  <pre><code>    public void onCreate(Bundle savedInstanceState)
      {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      TextView txt = (TextView) findViewById(R.id.textView1);
      txt.setText(getInputStreamFromUrl("http://192.168.37.241:8080/kyaw/ktest/a.jpg"));
      }
  
      public static String getInputStreamFromUrl(String url) {
            String content = null;
            HttpResponse response = null;
            try {
  
  DefaultHttpClient httpclient = new DefaultHttpClient();             
              HttpPut put=new HttpPut(url);
              File f=new File("C:\\downloads\\a.jpg");
              FileEntity reqEntity=new FileEntity(f,"images/jpg");
              put.setEntity(reqEntity);
              put.setHeader("Content-Type","application/vnd.org.snia.cdmi.dataobject");
              response = httpclient.execute(put);
              HttpEntity resEntity=response.getEntity();
              if(resEntity!=null)
              content = (EntityUtils.toString(resEntity));
            }catch (Exception e) {
              Log.e("PUT Exception", "java.lang.NullPointerException");
            }
              String result=response.getStatusLine().toString()+"\n"+content;
  
              return result;
          }
  </code></pre>