Skip to content

Instantly share code, notes, and snippets.

package KochCarles; // cal canviar-lo al teu nom
import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
/*
* Copyright 2016 Carles Koch Busquets
*
/*
* Animal.java
*
* Copyright 2010 Mònica Ramírez Arceda <[email protected]>
* This is free software, licensed under the GNU General Public License v3.
* See http://www.gnu.org/licenses/gpl.html for more information.
*
*/
package animals;
/*
Examen PLpgSQL
Carles Koch Busquets
*/
drop function afegirservei ( integer, integer, integer) ;
drop function checkin ( character varying) ;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
public class CSVUtils {
@ckob
ckob / filaCsvToArrString.java
Created April 25, 2016 17:39
Lector de csv
private char possibleDelimitadorCampsEntrada = '\"';
private char separadorEntrada = ',';
/**
*
* @param fila un string separat amb estil csv
* @return array de Strings amb un valor per cada camp separat correctament.
*/
public String[] filaCsvToArrString(String fila) {
ArrayList<String> strings = new ArrayList<>();
public BookTxt(String filePath) {
this.filePath = filePath;
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(this.filePath));
strFitxer = new ArrayList<>(5000); // 5k de linies inicials, falta buscar quantes serien més aproximadament a partir del tamany del fitxer.
String actualLine;
while ((actualLine = br.readLine()) != null) {
strFitxer.add(actualLine);
public int countWords() {
int totalWords=0;
for (String s : strFitxer) {
for (String i : s.split(" ")) {
if (!i.isEmpty()) {
totalWords++;
}
}
}
return totalWords;
Fitxer /var/lib/pgsql/data/postgresql.conf :
- listen_adresses='*'
- port=5432
(les dues anteriors descomentades)
Fitxer /var/lib/pgsql/data/pg_hba.conf:
(al apartat IPv4, afegir:)
- host all all 192.168.3.4/32 trust
(amb /32 només pot entrar el propi pc)
import java.util.ArrayList;
public class Ferry {
private String regNumber; // Matricula del ferry
private String name; // Nom del ferry
private String harbourName; // Nom del port destí del ferry
private double pricePerAxle;// Preu en € que cobra el ferry al camió per cada eix
private double pricePerTon; // Preu en € que cobra el ferry al camió per cada Tm de pes
private double maxWeight; // Pes màxim en Tm dels camions transportables pel ferry.
private ArrayList<Lorry> boardedLorries; // Els camions carregats al ferry
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
<entry name="!?*.form" />
<entry name="!?*.class" />
<entry name="!?*.groovy" />
<entry name="!?*.scala" />