org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder Java Examples
The following examples show how to use
org.springframework.batch.item.file.builder.FlatFileItemReaderBuilder.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CapitalizeNamesJobConfig.java From spring-batch with MIT License | 5 votes |
@Bean public FlatFileItemReader<Person> itemReader() { return new FlatFileItemReaderBuilder<Person>() .name("personItemReader") .resource(new ClassPathResource("csv/persons.csv")) .delimited().names(new String[] {"firstName", "lastName"}) .targetType(Person.class).build(); }
Example #2
Source File: SpringBatchConfiguration.java From tutorials with MIT License | 5 votes |
@Bean @StepScope public FlatFileItemReader<BookRecord> csvItemReader(@Value("#{jobParameters['file.input']}") String input) { FlatFileItemReaderBuilder<BookRecord> builder = new FlatFileItemReaderBuilder<>(); FieldSetMapper<BookRecord> bookRecordFieldSetMapper = new BookRecordFieldSetMapper(); LOGGER.info("Configuring reader to input {}", input); // @formatter:off return builder .name("bookRecordItemReader") .resource(new FileSystemResource(input)) .delimited() .names(TOKENS) .fieldSetMapper(bookRecordFieldSetMapper) .build(); // @formatter:on }
Example #3
Source File: SpringBatchScheduler.java From tutorials with MIT License | 5 votes |
@Bean public FlatFileItemReader<Book> reader() { return new FlatFileItemReaderBuilder<Book>().name("bookItemReader") .resource(new ClassPathResource("books.csv")) .delimited() .names(new String[] { "id", "name" }) .fieldSetMapper(new BeanWrapperFieldSetMapper<Book>() { { setTargetType(Book.class); } }) .build(); }
Example #4
Source File: BatchConfiguration.java From messaging with Apache License 2.0 | 5 votes |
@Bean @StepScope FlatFileItemReader<Contact> fileReader( @Value("file://#{jobParameters['file']}") Resource pathToFile) throws Exception { return new FlatFileItemReaderBuilder<Contact>().name("file-reader") .resource(pathToFile).targetType(Contact.class).delimited() .names("fullName,email".split(",")).build(); }
Example #5
Source File: BatchJobConfiguration.java From patient-batch-loader with GNU General Public License v3.0 | 5 votes |
@Bean @StepScope public FlatFileItemReader<PatientRecord> reader( @Value("#{jobParameters['" + Constants.JOB_PARAM_FILE_NAME + "']}")String fileName) { return new FlatFileItemReaderBuilder<PatientRecord>() .name(Constants.ITEM_READER_NAME) .resource( new PathResource( Paths.get(applicationProperties.getBatch().getInputPath() + File.separator + fileName))) .linesToSkip(1) .lineMapper(lineMapper()) .build(); }
Example #6
Source File: StepService0004.java From seed with Apache License 2.0 | 5 votes |
private FlatFileItemReader<Person> reader(){ return new FlatFileItemReaderBuilder<Person>() .name("step0001Reader") .resource(new FileSystemResource("/data/seedboot-batch.txt")) .strict(true) .encoding(SeedConstants.DEFAULT_CHARSET) .linesToSkip(1) .delimited().delimiter("|") .names(new String[]{"realName", "age", "birthDay"}) .targetType(Person.class).customEditors(SettleJobConfiguration.customEditors) .build(); }
Example #7
Source File: StepService0006.java From seed with Apache License 2.0 | 5 votes |
private FlatFileItemReader<Person> reader(){ return new FlatFileItemReaderBuilder<Person>() .name("step0001Reader") .resource(new FileSystemResource("/data/seedboot-batch.txt")) .strict(true) .encoding(SeedConstants.DEFAULT_CHARSET) .linesToSkip(1) .delimited().delimiter("|") .names(new String[]{"realName", "age", "birthDay"}) .targetType(Person.class).customEditors(SettleJobConfiguration.customEditors) .build(); }
Example #8
Source File: HelloWorldJobConfig.java From spring-batch with MIT License | 5 votes |
@Bean public FlatFileItemReader<Person> reader() { return new FlatFileItemReaderBuilder<Person>() .name("personItemReader") .resource(new ClassPathResource("csv/persons.csv")) .delimited().names(new String[] {"firstName", "lastName"}) .targetType(Person.class).build(); }
Example #9
Source File: BatchConfiguration.java From batch-processing-large-datasets-spring with MIT License | 5 votes |
@Bean public FlatFileItemReader<Voltage> reader() { return new FlatFileItemReaderBuilder<Voltage>() .name("voltItemReader") .resource(new ClassPathResource("Volts.csv")) .delimited() .names(new String[]{"volt", "time"}) .lineMapper(lineMapper()) .fieldSetMapper(new BeanWrapperFieldSetMapper<Voltage>() {{ setTargetType(Voltage.class); }}) .build(); }
Example #10
Source File: CapitalizeNamesJobConfig.java From spring-batch with MIT License | 5 votes |
@Bean public FlatFileItemReader<Person> itemReader() { return new FlatFileItemReaderBuilder<Person>() .name("personItemReader") .resource(new ClassPathResource("csv/persons.csv")) .delimited().names(new String[] {"firstName", "lastName"}) .targetType(Person.class).build(); }
Example #11
Source File: CapitalizeNamesJobConfig.java From spring-batch with MIT License | 5 votes |
@Bean public FlatFileItemReader<Person> itemReader() { return new FlatFileItemReaderBuilder<Person>() .name("personItemReader") .resource(new ClassPathResource("csv/persons.csv")) .delimited().names(new String[] {"firstName", "lastName"}) .targetType(Person.class).build(); }
Example #12
Source File: CapitalizeNamesJobConfig.java From spring-batch with MIT License | 5 votes |
@Bean public FlatFileItemReader<Person> itemReader() { return new FlatFileItemReaderBuilder<Person>() .name("personItemReader").delimited() .names(new String[] {"firstName", "lastName"}) .targetType(Person.class).build(); }
Example #13
Source File: PersonJobConfig.java From spring-batch-rest with Apache License 2.0 | 5 votes |
@Bean FlatFileItemReader<Person> personReader() { return new FlatFileItemReaderBuilder<Person>() .name("personItemReader") .resource(new ClassPathResource("person.csv")) .delimited() .names(new String[]{"firstName", "lastName"}) .fieldSetMapper(new BeanWrapperFieldSetMapper<Person>() {{ setTargetType(Person.class); }}) .build(); }
Example #14
Source File: PersonJobConfig.java From spring-batch-rest with Apache License 2.0 | 5 votes |
@Bean FlatFileItemReader<Person> personReader() { return new FlatFileItemReaderBuilder<Person>() .name("personItemReader") .resource(new ClassPathResource("person.csv")) .delimited() .names("firstName", "lastName") .fieldSetMapper(new BeanWrapperFieldSetMapper<Person>() {{ setTargetType(Person.class); }}) .build(); }
Example #15
Source File: BatchConfig.java From Software-Architecture-with-Spring-5.0 with MIT License | 5 votes |
@Bean public FlatFileItemReader<PayrollTo> reader() { return new FlatFileItemReaderBuilder<PayrollTo>() .name("payrollItemReader") .resource(new ClassPathResource("payroll-data.csv")) .delimited() .names(new String[]{"identification","currency","ammount","accountType", "accountNumber", "description", "firstLastName"}) .fieldSetMapper(new BeanWrapperFieldSetMapper<PayrollTo>() {{ setTargetType(PayrollTo.class); }}) .build(); }
Example #16
Source File: BatchConfiguration.java From spring-graalvm-native with Apache License 2.0 | 5 votes |
@Bean @StepScope public ItemStreamReader<CustomerCredit> itemReader() { return new FlatFileItemReaderBuilder<CustomerCredit>() .name("itemReader") .resource(new ClassPathResource("/customer.csv")) .delimited() .names("name", "credit") .targetType(CustomerCredit.class) .build(); }
Example #17
Source File: ConvertNamesJobConfig.java From spring-batch with MIT License | 4 votes |
@Bean public FlatFileItemReader<Person> itemReader() { return new FlatFileItemReaderBuilder<Person>().name("personItemReader") .resource(new ClassPathResource("csv/persons.csv")).delimited() .names(new String[] {"firstName", "lastName"}).targetType(Person.class).build(); }
Example #18
Source File: FlatFileItemReaderAutoConfiguration.java From spring-cloud-task with Apache License 2.0 | 4 votes |
@Bean @ConditionalOnMissingBean @ConditionalOnProperty(prefix = "spring.batch.job.flatfilereader", name = "name") public FlatFileItemReader<Map<Object, Object>> itemReader() { FlatFileItemReaderBuilder<Map<Object, Object>> mapFlatFileItemReaderBuilder = new FlatFileItemReaderBuilder<Map<Object, Object>>() .name(this.properties.getName()).resource(this.properties.getResource()) .saveState(this.properties.isSaveState()) .maxItemCount(this.properties.getMaxItemCount()) .currentItemCount(this.properties.getCurrentItemCount()) .strict(this.properties.isStrict()) .encoding(this.properties.getEncoding()) .linesToSkip(this.properties.getLinesToSkip()) .comments(this.properties.getComments() .toArray(new String[this.properties.getComments().size()])); if (this.lineTokenizer != null) { mapFlatFileItemReaderBuilder.lineTokenizer(this.lineTokenizer); } if (this.recordSeparatorPolicy != null) { mapFlatFileItemReaderBuilder .recordSeparatorPolicy(this.recordSeparatorPolicy); } if (this.fieldSetMapper != null) { mapFlatFileItemReaderBuilder.fieldSetMapper(this.fieldSetMapper); } if (this.lineMapper != null) { mapFlatFileItemReaderBuilder.lineMapper(this.lineMapper); } if (this.skippedLinesCallback != null) { mapFlatFileItemReaderBuilder.skippedLinesCallback(skippedLinesCallback); } if (this.properties.isDelimited()) { mapFlatFileItemReaderBuilder.delimited() .quoteCharacter(this.properties.getQuoteCharacter()) .delimiter(this.properties.getDelimiter()) .includedFields( this.properties.getIncludedFields().toArray(new Integer[0])) .names(this.properties.getNames()) .beanMapperStrict(this.properties.isParsingStrict()) .fieldSetMapper(new MapFieldSetMapper()); } else if (this.properties.isFixedLength()) { mapFlatFileItemReaderBuilder.fixedLength() .columns(this.properties.getRanges().toArray(new Range[0])) .names(this.properties.getNames()) .fieldSetMapper(new MapFieldSetMapper()) .beanMapperStrict(this.properties.isParsingStrict()); } return mapFlatFileItemReaderBuilder.build(); }