-4

Google ドキュメントにテキスト ファイルを保存しました。これは共有パブリック ファイルです。URLでそのファイルの内容を読み取ろうとしています。しかし、それはコンテンツを表示していません。ここにコードを添付しています。ファイルのコンテンツを読み取るためにコードをどこで変更すればよいか教えてください.URLで指定したアドレスは、Webブラウザのアドレスバーに書き込んでいるときにコンテンツを表示しています. 私は実際にコードを修正する場所を知りません。コードの最後に出力を追加しました

package FileContent;

import java.awt.*; 
import java.net.*; 
import java.io.*; 

public class FileContent extends Frame {
    public static void main(String[] args) {

        BufferedReader br = null;
        TextArea FileText = new TextArea("  Content of the File \'temp1.txt\' :", 11, 24, TextArea.SCROLLBARS_NONE);

        try {
            // here is the url
            URL url = new URL("https://docs.google.com/file/d/0B9MOgXFCss2iSWpicmVKSW9OOWM/edit");

            InputStream is = url.openStream();
            br = new BufferedReader(new InputStreamReader(is));
        } catch (MalformedURLException e) {
            System.out.println("Bad URL");
        } catch (IOException e) {
            System.out.println("IO Error : " + e.getMessage());
        }

        FileText.setBackground(Color.cyan);
        FileText.append(String.valueOf('\n'));

        Frame f = new Frame("File Content");
        f.setSize(200, 200);
        f.add(FileText);
        f.setVisible(true);

        try {
            String s;
            boolean eof = false;
            s = br.readLine();

            while (!eof) {
                FileText.append(s + String.valueOf('\n'));
                try {
                    s = br.readLine();
                    if (s == null) {
                        eof = true;
                        br.close();
                    }
                } catch (EOFException eo) {
                    eof = true;
                } catch (IOException e) {
                    System.out.println("IO Error : " + e.getMessage());
                }
            }

        } catch (IOException e) {
            System.out.println("IO Error : " + e.getMessage());
        }
    }    
}

出力は次のようになります。 ,"docs-collaborator-selection-model":false,"docs-csmbocj":false,"ecbsl":true,"ecid":true,"eod":true,"docs-eilb":false,"docs- pedd":true,"docs-evr":false,"docs-enmr":false,"docs-esrd":false,"share_ui":"jfk","server_time_ms":1378944177685,"gaia_session_id":"", "enable_iframed_embed_api":true,"cup":"/folder/d/{folderId}/edit","docs-fut":"//docs.google.com/#folders/{folderId}","esid": true,"esubid":false,"docs-etbs":true,"enable_kennedy":true,"onePickImportDocumentUrl":"","opbu":"https://docs.google.com/picker","opru":"https://docs.google.com/relay.html", "opdu":false,"ophi":"texmex","opuci":"","docs-se":false,"docs-ebcrsct":false,"docs-iror":false,"xdbcmUri":" https://docs.google.com/file/xdbcm.html","xdbcfAllowXpc":true,"docs-corsbc":false,"xdbcfAllowHostNamePrefix":true,"docs-spdy":false,"enable_client_docos":true ,"enable_anchored_docos":true,"enable_docos_tickle":true,"gv_int_native":true,"tpc":true,"enable_pinned_revisions":false,"enable_edit_blob_revisions":false,"upload_url":"https://docs.google.com/upload/resumableupload","enable_toolbar":true,"enable_feedback_button":false,"enable_microscope":true,"enable_manage_timed_text":true,"video_embed_type":"PREFER_FLASH","enable_maps_embed" :true,"maps_api_uri":"https://maps.googleapis.com/maps/api/js?key=AIzaSyBCjpnguVjzi6vS67NdBtyYuvCYz3yBxCY&sensor=false","maps_display_uri":"https://maps.google.com/maps"," docs_abuse_link":"https://docs.google.com/abuse?id=0B9MOgXFCss2iSWpicmVKSW9OOWM","enable_csi":true,"csi_service_name":"texmex","third_party_default_icon_urls":{"icon16":"//ssl.gstatic .com/docs/doclist/images/generic_app_icon_16.png","icon32":"//ssl.gstatic.com/docs/doclist/images/generic_app_icon_32.png","icon64":"//ssl.gstatic.com/docs/doclist/images/generic_app_icon_64.png","icon128":"//ssl.gstatic.com/ docs/doclist/images/generic_app_icon_128.png"},"enable_chrome_webstore_link":true};(function(){(function(){function d(a){this.t={};this.tick=function(a, c,b){b=void 0!=b?b:(新しい日付).getTime();this.t[a]=[b,c]};this.tick("開始",null,a) }var a=new d;window.jstiming={Timer:d,load:a};if(window.performance&&window.performance.timing){var a=window.performance.timing,c=window.jstiming.load,b =a.navigationStart,a=a.responseStart;0=b&&(c.tick("com/docs/doclist/images/generic_app_icon_128.png"},"enable_chrome_webstore_link":true};(関数(){(関数(){関数d(a){this.t={};this.tick=関数( a,c,b){b=void 0!=b?b:(新しい日付).getTime();this.t[a]=[b,c]};this.tick("開始",null, a)}var a=new d;window.jstiming={Timer:d,load:a};if(window.performance&&window.performance.timing){var a=window.performance.timing,c=window.jstiming.load ,b=a.navigationStart,a=a.responseStart;0=b&&(c.tick("com/docs/doclist/images/generic_app_icon_128.png"},"enable_chrome_webstore_link":true};(関数(){(関数(){関数d(a){this.t={};this.tick=関数( a,c,b){b=void 0!=b?b:(新しい日付).getTime();this.t[a]=[b,c]};this.tick("開始",null, a)}var a=new d;window.jstiming={Timer:d,load:a};if(window.performance&&window.performance.timing){var a=window.performance.timing,c=window.jstiming.load ,b=a.navigationStart,a=a.responseStart;0=b&&(c.tick("タイミング){var a=window.performance.timing,c=window.jstiming.load,b=a.navigationStart,a=a.responseStart;0=b&&(c.tick("タイミング){var a=window.performance.timing,c=window.jstiming.load,b=a.navigationStart,a=a.responseStart;0=b&&(c.tick("画像を検索 マップ 再生 YouTube ニ​​ュース Gmail ドライブ 詳細 »不正使用を報告 | 設定 | サインイン temp1.txt コメント 共有サポートされていないブラウザーを使用しています。一部の機能が正しく動作しない場合があります。Google Chrome などの最新のブラウザにアップグレードしてください。

FileEditViewHelp DOCS_initializeModules({"core":[],"app":["core"]},{"core":["/static/file/client/js/123932484-edit_core__en_gb.js"],"app": ["/static/file/client/js/1118393582-edit_app__en_gb.js"]}, 'core');_main('/file/d/0B9MOgXFCss2iSWpicmVKSW9OOWM', {'sid': '6249ba6d18211909','id': ' 0B9MOgXFCss2iSWpicmVKSW9OOWM', 'email': '', 'title': 'temp1.txt', 'description': '', 'mimetype': 'text/plain', 'fileExtension': 'txt', 'mediaType': ' text', 'revisions': [{"tags":[],"creatorDisplayName":"Kawsar Jahan","pinned":true,"filename":"temp1.txt","downloadUrl":"https://docs.google.com/uc?id=0B9MOgXFCss2iSWpicmVKSW9OOWM&export=download&revid=0B9MOgXFCss2iaWN0a2p2b2x4dW4zcDBVL2lhTGhTajBaS3RnPQ","sizeInBytes":161,"docId":"0B9MOgXFCss2iaWN0a2p2b2x4dW4zcDBVL2lhTGhTajBaS3RnPQ","creationDateString":"10 Sep","creator":{"isMe" :false,"nickname":"Kawsar Jahan","iconUrl":"images/doclist/contact_nopicture.png","editProfileUrl":"editProfile"}}],'obfuscatedUserId': 'ANONYMOUS_17612595759507348808','userDomain': ' ', 'embedPreviewUri': 'https://docs.google.com/file/d/0B9MOgXFCss2iSWpicmVKSW9OOWM/preview','syncUpdates': [],'contentRenderer': 'gviewembed'},{"説明":{"raw ":""","フォーマットされた":""},"download":{"isMissingBlobRef":false,"filename":"temp1.txt","url":"https://docs.google.com/uc?id=0B9MOgXFCss2iSWpicmVKSW9OOWM&export=download "},"revision":{"swfUrl":"/static/doclist/client/css/1531528182-uploaderapi.swf","busyIconImageUrl":"https://ssl.gstatic.com/docs/doclist/images/ loading_small.gif"},"sharing":{"is_private":false,"visibility_is_restricted_to_domain":false,"visibility_domain_display_name":""},"basicdetails":{"mimeType":"text/plain","lastModifiedDateString": "10 Sep","creationDateString":"10 Sep","fileSize":"161"},"thumbnail":{"thumbnail_128":"https://lh4.googleusercontent.com/2lZYaNUzET3ObPtUlsycnF6LhTh_q0Q8GAyE8_F9Ic4IE_9o00anRyEAmglCuSwp_Jo2=s128","thumbnail_full":"https://lh4.googleusercontent.com/2lZYaNUzET3ObPtUlsycnF6LhTh_q0Q8GAyE8_F9Ic4IE_9o00anRyEAmglCuSwp_Jo2=s1600"},"gviewembed":{"url":" https://docs.google.com/viewer?srcid=0B9MOgXFCss2iSWpicmVKSW9OOWM&pid=explorer&efh=false&a=v","embeduri":"https://docs.google.com/viewer?srcid=0B9MOgXFCss2iSWpicmVKSW9OOWM&pid=explorer&efh=false&a=v&chrome= false&embedded=true","nonredirectedgviewurl":"https://docs.google.com/viewer?srcid=0B9MOgXFCss2iSWpicmVKSW9OOWM&pid=explorer&efh=false&a=v&chrome=true&redirect=false","isNativeGView":false},"webstoreui":{"mimeType":"text/plain","fileExtension":"txt","moreDriveAppsUrl":"https://chrome.google.com/webstore/category/collection/drive_apps"}});

4

1 に答える 1