Returns the CSV output file data.
@param lines The lines to add to the output file
@return The byte array representing the CSV output file data
335957
private byte[] getCSVOutput(List<String[]> lines)
    {
        StringWriter writer = new StringWriter();
        csv = new CSVWriter(writer, delimiter.separator().charAt(0));
        for(int i = 0; i < lines.size(); i++)
        {
            csv.writeNext((String[])lines.get(i), quotes);
        }

        // The contents returned is the CSV string
        return writer.toString().getBytes();
    }
860947
public static List<String> readLinesInList(final File input, final String encoding)
		throws IOException
	{
		// The List where the lines from the File to put.
		final List<String> output = new ArrayList<>();
		try (BufferedReader reader = (BufferedReader)StreamExtensions.getReader(input, encoding,
			false))
		{
			// the line.
			String line = null;
			// read all lines from the file
			do
			{
				line = reader.readLine();
				// if null break the loop
				if (line == null)
				{
					break;
				}
				// add the line to the list
				output.add(line);
			}
			while (true);
		}
		catch (final IOException e)
		{
			throw e;
		}
		// return the list with all lines from the file.
		return output;
	}
543908
public static ArrayList<Line> getLinesInTextFile(String encoding, File file) throws IOException {
		ArrayList<Line> lines = new ArrayList<Line>();
		FileInputStream inputStream = new FileInputStream(file);
		InputStreamReader inputReader = null;
		if(encoding != null) {
			inputReader = new InputStreamReader(inputStream, encoding);
		} else {
			inputReader = new InputStreamReader(inputStream);
		}
		//FileReader fileReader = new FileReader(file);
		BufferedReader reader = new BufferedReader(inputReader);
		String line; int count = 0;
		while ((line = reader.readLine()) != null) {
			count++;
			lines.add(new Line(file.getName(), count, line));
		}
		reader.close();
		return lines;
	}
699359
protected void spoolInputStream()
   {
      if (spoolFile != null || data != null) // already spooled
      {
         return;
      }

      byte[] buffer = new byte[0];
      byte[] tmpBuff = new byte[2048];
      int read = 0;
      int len = 0;
      SpoolFile sf = null;
      OutputStream sfout = null;

      try
      {
         while ((read = stream.read(tmpBuff)) >= 0)
         {
            if (sfout != null)
            {
               // spool to temp file
               sfout.write(tmpBuff, 0, read);
               len += read;
            }
            else if (len + read > spoolConfig.maxBufferSize)
            {
               // threshold for keeping data in memory exceeded,
               // if have a fileCleaner create temp file and spool buffer contents.
               sf = SpoolFile.createTempFile("jcrvd", null, spoolConfig.tempDirectory);
               sf.acquire(this);

               sfout = PrivilegedFileHelper.fileOutputStream(sf);

               sfout.write(buffer, 0, len);
               sfout.write(tmpBuff, 0, read);
               buffer = null;
               len += read;
            }
            else
            {
               // reallocate new buffer and spool old buffer contents
               byte[] newBuffer = new byte[len + read];
               System.arraycopy(buffer, 0, newBuffer, 0, len);
               System.arraycopy(tmpBuff, 0, newBuffer, len, read);
               buffer = newBuffer;
               len += read;
            }
         }

         if (sf != null)
         {
            // spooled to file
            this.spoolFile = sf;
            this.data = null;
         }
         else
         {
            // ...bytes
            this.spoolFile = null;
            this.data = buffer;
         }
      }
      catch (IOException e)
      {
         if (sf != null)
         {
            try
            {
               sf.release(this);
               spoolConfig.fileCleaner.addFile(sf);
            }
            catch (FileNotFoundException ex)
            {
               if (LOG.isDebugEnabled())
               {
                  LOG.debug("Could not remove temporary file : " + sf.getAbsolutePath());
               }
            }
         }

         throw new IllegalStateException("Error of spooling to temp file from " + stream, e);
      }
      finally
      {
         try
         {
            if (sfout != null)
            {
               sfout.close();
            }
         }
         catch (IOException e)
         {
            LOG.error("Error of spool output close.", e);
         }

         this.stream = null;
      }
   }
139837
private boolean tokenizeCSVLine(CSVFile             csvFile, 
                                    BufferedReader      reader,
                                    Map<String, String> fieldMap) {
        fieldMap.clear();
        m_token.setLength(0);
        
        // First build a list of tokens found in the order they are found.
        List<String> tokenList = new ArrayList<String>();
        boolean bInQuote = false;
        int aChar = 0;
        try {
            while (true) {
                aChar = reader.read();
                if (aChar < 0) {
                    break;
                }
                
                if (!bInQuote && aChar == ',') {
                    tokenList.add(m_token.toString());
                    m_token.setLength(0);
                } else if (!bInQuote && aChar == '\r') {
                    tokenList.add(m_token.toString());
                    m_token.setLength(0);
                    reader.mark(1);
                    aChar = reader.read();
                    if (aChar == -1) {
                        break; 
                    }
                    if (aChar != '\n') {
                        reader.reset(); // put back non-LF
                    }
                    break;
                } else if (!bInQuote && aChar == '\n') {
                    tokenList.add(m_token.toString());
                    m_token.setLength(0);
                    break;
                } else if (aChar == '"') {
                    bInQuote = !bInQuote;
                } else {
                    m_token.append((char)aChar);
                }
            }
        } catch (IOException e) {
            logErrorThrow("I/O error reading file", e.toString());
        }

        // If we hit EOF without a final EOL, we could have a token in the buffer.
        if (m_token.length() > 0) {
            tokenList.add(m_token.toString());
            m_token.setLength(0);
        }
        
        if (tokenList.size() > 0) {
            for (int index = 0; index < tokenList.size(); index++) {
                String token = tokenList.get(index).trim();
                if (token.length() > 0) {
                    String fieldName = csvFile.m_fieldList.get(index);
                    fieldMap.put(fieldName, token);
                }
            }
            return true;
        }
        
        // No tokens found; return false if EOF.
        return aChar != -1;
    }
184063
private static String[] getNmeaItems(String line) {
        String[] items = StringUtils.splitByWholeSeparatorPreserveAllTokens(line,
                PARAMETER_DELIMITER);
        // remove the checksum from the end
        String last = items[items.length - 1];
        if (last.contains("*"))
            items[items.length - 1] = last.substring(0, last.lastIndexOf('*'));
        return items;
    }
992866
private static byte[] writeCsv(String[] columnHeaders, String[][] rows) throws IOException {
    try (ByteArrayOutputStream csvStream = new ByteArrayOutputStream(); OutputStreamWriter streamWriter = new OutputStreamWriter(csvStream, Charset.forName("UTF-8"))) {
      CSVWriter csvWriter = new CSVWriter(streamWriter, ',');

      csvWriter.writeNext(columnHeaders);
      
      for (String[] row : rows) {
        csvWriter.writeNext(row);
      }

      csvWriter.close();
      
      return csvStream.toByteArray();
    }
  }
223475
public static byte[] copyToByteArray(File in) throws IOException {
		Assert.notNull(in, "No input File specified");
		return copyToByteArray(new BufferedInputStream(new FileInputStream(in)));
	}
913592
public static List<String> linesFromFile(String filename,String encoding) {
    try {
      List<String> lines = new ArrayList<String>();
      BufferedReader in = new BufferedReader(new EncodingFileReader(filename,encoding));
      String line;
      while ((line = in.readLine()) != null) {
        lines.add(line);
      }
      in.close();
      return lines;
    }
    catch (IOException e) {
      e.printStackTrace();
      return null;
    }
  }
265181
public byte[] getOutput() {
		if (stringWriter != null) {
			byte[] output = null;

			String string = stringWriter.toString();
			if (string != null) {
				try {
					output = string.getBytes(characterEncoding);
				} catch (UnsupportedEncodingException uue) {
					output = null;
				}
			}

			return output;
		} else if (outputStream != null) {
			return outputStream.getOutput();
		}

		return null;
	}
640801
public static String[] getDataFromLine(final String line, final String seperator)
	{
		return getDataFromLine(line, seperator, false);
	}
973347
public static void writeFile( List<String> lines, String filePath ) throws IOException {
        writeFile(lines, new File(filePath));
    }
498743
public static String[] disectCommandLine(String line) {
		return StringSupport.split(line, "() ,;", "\"", false, false, false).toArray(new String[0]);
	}
245518
public void generateCSV() {
        
        int cont = 0;
        int algorithmSize = this.streams.get(0).algorithm.size();
        int streamSize = this.streams.size();
        int measureSize = this.streams.get(0).algorithm.get(0).measures.size();
        
        while (cont != measureSize) {
            String output = "";
            output += "Algorithm,";
            output += this.streams.get(0).algorithm.get(0).name;
            //Inicialize summary table
            
            for (int i = 1; i < algorithmSize; i++) {
                output += "," + this.streams.get(0).algorithm.get(i).name;
               
            }
            output += "\n";

            for (int i = 0; i < streamSize; i++) {
                List<Algorithm> alg = this.streams.get(i).algorithm;
                output += this.streams.get(i).name;
                for (int j = 0; j < algorithmSize; j++) {
                    output += "," + alg.get(j).measures.get(cont).getValue();
                    
                }
                output += "\n";
            }
            //PrintStream out = null;
            String name = this.streams.get(0).algorithm.get(0).measures.get(cont).getName();
//            try {
//                out = new PrintStream(new BufferedOutputStream(new FileOutputStream(path + name + ".csv")));
//            } catch (FileNotFoundException ex) {
//                Logger.getLogger(Summary.class.getName()).log(Level.SEVERE, null, ex);
//            }
//            System.setOut(out);
//            System.out.println(output);
//            out.close();
            try {
            BufferedWriter out = new BufferedWriter(new FileWriter(path + name + ".csv"));
            out.write(output);  //Replace with the string 
            //you are trying to write  
            out.close();
        } catch (IOException e) {
            System.out.println(name + ".csv");

        }
            cont++;
        }

    }
919770
private String createCSV() {

        String csvData = null;

        if (isAggregate())
            csvData = createAggregatedProjectCSV();
        else
            csvData = createMultiProjectCSV();

        return csvData;
    }
907251
public OutputStream getOutput(GridFile file) throws IOException {
      checkIsNotDirectory(file);
      createIfNeeded(file);
      return new GridOutputStream(file, false, data);
   }
890428
public static String getCsvFileAsSqlInsertScript(final String tableName, final String[] headers,
		final String[] columnTypes, final List<String[]> lines)
	{
		return getCsvFileAsSqlInsertScript(tableName, new CsvBean(headers, columnTypes, lines));
	}