Package be.bagofwords.virtualfile

Examples of be.bagofwords.virtualfile.VirtualFile


            byte actionAsByte = connection.readByte();
            try {
                Action action = Action.values()[actionAsByte];
                if (action == Action.INPUT_STREAM) {
                    String relPath = connection.readString();
                    VirtualFile file = virtualFileService.getRootDirectory().getFile(relPath);
                    if (file.exists()) {
                        InputStream is = file.createInputStream();
                        connection.writeLong(LONG_OK);
                        IOUtils.copy(is, connection.getOs());
                        connection.flush();
                    } else {
                        connection.writeLong(LONG_ERROR);
                        connection.writeString("Could not find file " + relPath);
                        connection.flush();
                    }
                } else if (action == Action.OUTPUT_STREAM) {
                    String relPath = connection.readString();
                    VirtualFile file = virtualFileService.getRootDirectory().getFile(relPath);
                    OutputStream os = file.createOutputStream();
                    connection.writeLong(LONG_OK);
                    connection.flush();
                    IOUtils.copy(connection.getIs(), os);
                } else if (action == Action.EXISTS) {
                    String relPath = connection.readString();
                    VirtualFile file = virtualFileService.getRootDirectory().getFile(relPath);
                    connection.writeBoolean(file.exists());
                    connection.flush();
                } else {
                    connection.writeLong(LONG_ERROR);
                    connection.writeString("Unknown command " + action);
                    connection.flush();
View Full Code Here

TOP

Related Classes of be.bagofwords.virtualfile.VirtualFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.