добрый вечер, подскажите пожалуйста, как считать второй аргумент с пробелами,
чтобы (к примеру) args[1] = "куртка для сноубордистов"
а не
args[1] = "куртка"
args[2] = "для"
args[3] = "сноубордистов"
или может в другом проблема тут?
package com.javarush.task.task18.task1827;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/*
Прайсы
*/
public class Solution {
public static void main(String[] args) throws Exception {
if(args.length ==0){return;}
Scanner scan = new Scanner(System.in);
String fileAction = scan.nextLine();
BufferedReader bufferedReader = new BufferedReader(new FileReader(fileAction));
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(fileAction, true));
String line = "";
String id = "";
File file = new File(fileAction);
if (file.length() == 0){
id = "1 ";
}
int tmp = Integer.MIN_VALUE;
while((line = bufferedReader.readLine()) != null){
String idBeta = line.substring(0,8).trim();
int res = Integer.parseInt(idBeta);
if (res > tmp){
tmp = res;
}
}
tmp++;
id = String.valueOf(tmp);
for(int i = id.length(); i<8; i++){
id += " ";
}
String action = args[0];
String allValues = id;
switch (action){
case ("-c") :
String productName = args[1];
String product = "";
if(productName.length() >= 30){
product = productName.substring(0,30);
} else if (productName.length() < 30) {
product = productName;
for (int i = productName.length(); i < 30; i++) {
product += " ";
}
}
String priceBeta = args[2];
String price = "";
if(priceBeta.length() >= 8){
price = priceBeta.substring(0,8);
} else if (priceBeta.length() < 8) {
price = priceBeta;
for (int i = price.length(); i < 8; i++) {
price += " ";
}
}
String quantityBeta = args[3];
String quantity = "";
if(quantityBeta.length() >= 4){
quantity = quantityBeta.substring(0,4);
} else if (quantityBeta.length() < 4) {
quantity = quantityBeta;
for (int i = quantity.length(); i < 4; i++) {
quantity += " ";
}
}
allValues += product + price + quantity + "\n";
break;
}
//System.out.println(allValues);
bufferedWriter.write(allValues);
bufferedWriter.flush();
bufferedWriter.close();
bufferedReader.close();
}
}