A query to get the contents of a file. Queries do not change the state of the file or require network consensus. The information is returned from a single node processing the query.Query Signing Requirements
The client operator private key is required to sign the query request
Query Fees
Please see the transaction and query fees table for the base transaction fee
//Create the queryFileContentsQuery query = new FileContentsQuery() .setFileId(newFileId);//Sign with client operator private key and submit the query to a Hedera networkByteString contents = query.execute(client);//Change to Utf-8 encodingString contentsToUtf8 = contents.toStringUtf8();System.out.println(contentsToUtf8);//v2.0.0
//Create the queryconst query = new FileContentsQuery() .setFileId(newFileId);//Sign with client operator private key and submit the query to a Hedera networkconst contents = await query.execute(client);console.log(contents.toString());//v2.0.7
//Create the queryquery := hedera.NewFileContentsQuery(). SetFileID(newFileId)//Sign with client operator private key and submit the query to a Hedera networkcontents, err := query.Execute(client)fmt.Println(string(contents))//v2.0.0
// Create the querylet query = FileContentsQuery::new() .file_id(file_id);// Submit the query to a Hedera networklet contents = query.execute(&client).await?;// Print the contents to the consoleprintln!("File contents: {:?}", String::from_utf8_lossy(&contents));// v0.34.0