How to update already existing file in google drive api v3 java
<p>I have tried with the following code... Without any luck...</p>

<pre><code>private void updateFile(Drive service, String fileId) {
        try {
            File file = new File(); /********/
            final java.io.File fileToUpdate = new java.io.File("D:/Work Data/Files/pdf.pdf");
            FileContent mediaContent = new FileContent("image/pdf", fileToUpdate);
            file = service.files().update(fileId, file, mediaContent).execute();
            System.out.println(fileId);
        } catch (Exception e) {
            if (isDebug) {
                e.printStackTrace();
            }
        }    
    }
</code></pre>

<p>also tried with... </p>

<pre><code> private void updateFile(Drive service, String fileId) {
        try {
            File file = service.files().get(fileId).execute(); /********/
            final java.io.File fileToUpdate = new java.io.File("D:/Work Data/Files/pdf.pdf");
            FileContent mediaContent = new FileContent("image/pdf", fileToUpdate);
            file = service.files().update(fileId, file, mediaContent).execute();
            System.out.println(fileId);
        } catch (Exception e) {
            if (isDebug) {
                e.printStackTrace();
            }
        }    
    }
</code></pre>

<p>With every time i execute the code i get the following stacktrace: </p>

<pre><code>java.lang.IllegalArgumentException
    at com.google.api.client.repackaged.com.google.common.base.Preconditions.checkArgument(Preconditions.java:111)
    at com.google.api.client.util.Preconditions.checkArgument(Preconditions.java:37)
    at com.google.api.client.googleapis.media.MediaHttpUploader.setInitiationRequestMethod(MediaHttpUploader.java:872)
    at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.initializeMediaUpload(AbstractGoogleClientRequest.java:237)
    at com.google.api.services.drive.Drive$Files$Update.&lt;init&gt;(Drive.java:3163)
    at com.google.api.services.drive.Drive$Files.update(Drive.java:3113)
    at com.test.DriveTester.updateFile(DriveTester.java:76)
    at com.test.DriveTester.main(DriveTester.java:64)
</code></pre>

<p>Can anyone tell what i am doing wrong ? Any sample code for this i.e. updating the content of an already existing file on google drive will be helpful...</p>