0
I’m creating a program whose idea was to take a text with a few words and break them in ","
. Only you are reading only up to a part of the text.
Follow the code and text below:
public static void main(String[] args) {
String colunas = "";
System.out.println("Cole o texto a ser quebrado por virgula :");
Scanner entrada = new Scanner(System.in);
while (entrada.hasNext()) {
if(entrada.nextLine() == null || entrada.nextLine().equals(""))
{
break;
}
colunas += entrada.nextLine();
}
//colunas = entrada.nextLine();
String[] split = colunas.trim().split(",");
for (String c : split) {
System.out.println("FIELD " + c + " AS CHAR");
}
}
and here text I want to break the words (they have to continue with ""
because I will use it in another language only ""
and space between them )
"PETROLEO", "PESTANA", "PESTILENTO", "PETELECO", "REBOQUE", "CADARCO",
"CADEIRA", "COLA", "REBENTO", "DEFUMADO", "DISCURSO", "ELETRODOMESTICO",
"ELETRONICA", "ENGRENAGEM", "ESFOMEADO", "FERRALHEIRO", "FERROVIA",
"FERTIL", "FORTALEZA", "FORTIFICANTE", "OFICINA", "ORNAMENTO", "PALAVRA",
"PREOCUPACAO", "RADIOLOGIA", "RADIOGRAFIA", "GRANJA", "GRANULADO", "INDUZIDO",
"IMBATIVEL", "INDUSTRIA", "INTERNACIONAL", "LABIRINTO", "LOBISOMEM",
"LOCOMOTIVA", "TESOURA", "MASSAGISTA", "MATADOURO", "MOCHILA", "NOROESTE",
"NITROGLICERINA", "HELICOPTERO", "CAPITALISMO", "SOFTWARE", "ENGENHARIA",
"NOROESTE", "AUTENTICO", "LINUX", "PROCESSADOR", "QUARENTENA", "MEDICINA",
"HOLOCAUSTO", "RADIOGRAFIA", "XAROPE", "ZAROLHO", "ZOOLOGICO", "HEREDITARIO",
"EXTASE", "EXTRAVIO", "DUODENO", "ECOLOGISTA", "TURISMO", "TRAFICANTE",
"CONSELHO", "BAIXISTA", "AVESTRUZ", "QUIMICA", "BOTANICA", "RESPECTIVO",
"SAXOFONE", "TABERNA", "OCULTO", "TRIGONOMETRIA", "ZODIACO", "JUSTAPOSTO",
"HIDRAULICO", "HEXAGONO", "MINEIRO", "FRENETICO", "EXPLOSIVEL", "EXORCISTA"
then when I run the program it displays nothing, if I take the while and switch to the columns = input.nextLine(); it displays only up to the Tab of the text
– Alef Ribeiro
@Alefribeiro was not to remove the while, was to make the changes I showed in the answer, the problem was your if.
– user28595
but I switched for your while and even then it didn’t work
– Alef Ribeiro
@Alefribeiro the nexline method only takes one line, if you pass text with multiple lines it will not catch everything. This may be the problem.
– user28595
Yes, but I’ve tried with only Next and it didn’t work either, when this with the while you run and it stops at reading nor gets to display anything, it had never happened that
– Alef Ribeiro