Created
October 5, 2019 17:06
-
-
Save Daniel-Dos/4f1cb3d0c4e15de38aeb843e87170eaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import java.io.InputStreamReader; | |
import java.util.ArrayList; | |
import java.util.List; | |
import javax.enterprise.context.ApplicationScoped; | |
import javax.inject.Inject; | |
import org.apache.deltaspike.cdise.api.CdiContainer; | |
import org.apache.deltaspike.cdise.api.CdiContainerLoader; | |
import org.apache.deltaspike.cdise.api.ContextControl; | |
import org.apache.deltaspike.core.api.provider.BeanProvider; | |
import org.apache.deltaspike.core.api.resourceloader.InjectableResource; | |
@ApplicationScoped | |
public class MainApplication { | |
@Inject | |
@InjectableResource(location="palestrante.txt") | |
private InputStream inputStream; | |
public InputStream getInputStream() { | |
return inputStream; | |
} | |
public static void main(String[] args) { | |
CdiContainer cdiContainer = CdiContainerLoader.getCdiContainer(); | |
cdiContainer.boot(); | |
ContextControl contextControl = cdiContainer.getContextControl(); | |
contextControl.startContext(ApplicationScoped.class); | |
MainApplication mainApplication = BeanProvider.getContextualReference(MainApplication.class); | |
List<Palestrante> palestrantes = new ArrayList<>(); | |
try (BufferedReader palestranteTxt= new BufferedReader(new InputStreamReader(mainApplication.getInputStream()))) { | |
palestranteTxt.lines().forEach(palestrante-> { | |
String[] output = palestrante.split("-"); | |
palestrantes.add(new Palestrante(output[0], output[1], output[2])); | |
}); | |
} catch (IOException e) { | |
e.printStackTrace(); | |
} | |
palestrantes.forEach(System.out::println); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment