Independentsoft
- any library, any programming language
Home
Purchase
Support
Company
Contact
JShare
>
Tutorial
> List files
The following example shows you how to list files in a folder.
import java.util.List; import com.independentsoft.share.File; import com.independentsoft.share.Service; import com.independentsoft.share.ServiceException; public class Example { public static void main(String[] args) { try { Service service = new Service("https://independentsoft.sharepoint.com", "username", "password"); List
files = service.getFiles("/"); for (int i = 0; i < files.size(); i++) { System.out.println("Name: " + files.get(i).getName()); System.out.println("Path: " + files.get(i).getServerRelativeUrl()); System.out.println("Length: " + files.get(i).getLength()); System.out.println("LastModifiedTime: " + files.get(i).getLastModifiedTime()); System.out.println("---------------------------------------------"); } List
files2 = service.getFiles("/Shared Documents"); for (int i = 0; i < files2.size(); i++) { System.out.println("Name: " + files2.get(i).getName()); System.out.println("Path: " + files2.get(i).getServerRelativeUrl()); System.out.println("Length: " + files2.get(i).getLength()); System.out.println("LastModifiedTime: " + files2.get(i).getLastModifiedTime()); System.out.println("---------------------------------------------"); } } catch (ServiceException ex) { System.out.println("Error: " + ex.getMessage()); System.out.println("Error: " + ex.getErrorCode()); System.out.println("Error: " + ex.getErrorString()); System.out.println("Error: " + ex.getRequestUrl()); ex.printStackTrace(); } } }
Need help? Ask our developers:
Name*
Email*
Message*