독서 구글은 기어와 함께 JavaScript
-
22-07-2019 - |
문제
누군가하는 방법을 알고 읽는 google 기어 blob 개체 내의 브라우저는 무엇입니까?내가 사용하여 gwt 의 상단에 장치지만,나는 어떠한 종류의 솔루션입니다.응용 프로그램이 필요한은 완전히 오프라인으로 작업 할 수 있도록 게시 및 파일정을 서버 측.나 파일은 단순한 텍스트 파일 내가 원하는 업로드하고 분석 오프라인 모드에서.
해결책
나는 아주 간단한 클래스에 이것을 하는 당신은 여기에서 확인하실 수 있습니다:http://procbits.com/2009/07/29/read-file-contents-blobs-in-gwt-and-gears/
그것은 사용하기 매우 간단합니다.거나 전화 방법"readAllText"또는 당신은 그것을 읽을 수 있는 줄.여기에 예를 읽을 줄:
try {
Desktop dt = Factory.getInstance().createDesktop();
dt.openFiles(new OpenFilesHandler(){
public void onOpenFiles(OpenFilesEvent event) {
File[] files = event.getFiles();
File file = files[0];
Blob data = file.getBlob();
BlobReader br = new BlobReader(data);
while (!br.endOfBlob())
Window.alert(br.readLine());
}
}, true);
} catch (Exception ex){
Window.alert(ex.toString());
}
이 도움이 되었으면 좋겠습니다!
다른 팁
당신이 보았 Google 장치 API 를 설명서 (JavaScript)?
제휴하지 않습니다 StackOverflow