MyTetra Share
Делитесь знаниями!
Groovy доступ к файлу
Время создания: 20.11.2019 17:08
Раздел: INFO - JOB - CUBA - GroovyScripts
Запись: wwwlir/Tetra/master/base/1574240917ph433gcgql/text.html на raw.githubusercontent.com

import com.groupstp.rtneo.entity.*

import java.util.*

import com.haulmont.cuba.core.global.*

import com.groupstp.rtneo.entity.*

import com.groupstp.rtneo.core.bean.calculation.CalculationWorkerHelper

import com.haulmont.cuba.core.entity.FileDescriptor

import com.haulmont.cuba.core.app.FileStorageAPI

import java.io.InputStream

import java.io.InputStreamReader

import java.io.ByteArrayOutputStream

import org.apache.commons.io.IOUtils




DataManager dataManager = AppBeans.get(DataManager.NAME)

CalculationWorkerHelper helper = AppBeans.get(CalculationWorkerHelper.NAME)

FileStorageAPI fileStorageAPI=AppBeans.get(FileStorageAPI.NAME);



String id='d2af026a-c82d-0763-e2fe-d76e392af599'



FileDescriptor fd = dataManager.load(FileDescriptor.class)

.id(UuidProvider.fromString(id))

.view(View.MINIMAL)

.optional()

.orElse(null);

if (fd == null) {

throw new RuntimeException(getMessage("BigTrioContractImporterBean.fileNotFound"));

}


InputStream inputStream=fileStorageAPI.openStream(fd)


String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);

==========================================================================================

import com.groupstp.rtneo.entity.*

import java.util.*

import com.haulmont.cuba.core.global.*

import com.groupstp.rtneo.entity.*

import com.groupstp.rtneo.core.bean.calculation.CalculationWorkerHelper

import com.haulmont.cuba.core.entity.FileDescriptor

import com.haulmont.cuba.core.app.FileStorageAPI

import java.io.InputStream

import java.io.InputStreamReader

import java.io.ByteArrayOutputStream

import org.apache.commons.io.IOUtils

import java.nio.charset.StandardCharsets;

import com.opencsv.CSVReader;



DataManager dataManager = AppBeans.get(DataManager.NAME)

CalculationWorkerHelper helper = AppBeans.get(CalculationWorkerHelper.NAME)

FileStorageAPI fileStorageAPI=AppBeans.get(FileStorageAPI.NAME);



String id='ee24428d-3a68-4a89-f72a-20928254f51c'



FileDescriptor fd = dataManager.load(FileDescriptor.class)

.id(UuidProvider.fromString(id))

.view(View.MINIMAL)

.optional()

.orElse(null);

if (fd == null) {

throw new RuntimeException(getMessage("BigTrioContractImporterBean.fileNotFound"));

}


InputStream inputStream=fileStorageAPI.openStream(fd)


CSVReader reader = new CSVReader(new InputStreamReader(inputStream, "UTF-8"));


for(row in reader)

{

log.debug(row[1])

}

Так же в этом разделе:
 
MyTetra Share v.0.65
Яндекс индекс цитирования