List of usage examples for java.util List toString
public String toString()
From source file:coding.cowboys.scrapers.DvcMagicResalesScraper.java
public static void main(String[] args) { DvcMagicResalesScraper test = new DvcMagicResalesScraper(); List<ResortWrapper> hello = test.findResorts(); System.out.println(hello.toString()); }
From source file:com.soa.facepond.util.JsonUtil.java
public static void main(String[] args) { List<String> list = JsonUtil.getStrListFromJsonArray("[\"app101.serve\", \"app102.serve\"]"); System.out.println(list.toString()); }
From source file:com.netflix.genie.client.sample.CommandServiceSampleClient.java
/** * Main for running client code.//from w w w.j av a 2 s . c o m * * @param args program arguments * @throws Exception on issue. */ public static void main(final String[] args) throws Exception { // Initialize Eureka, if it is being used // LOG.info("Initializing Eureka"); // ApplicationServiceClient.initEureka("test"); LOG.info("Initializing list of Genie servers"); ConfigurationManager.getConfigInstance().setProperty("genie2Client.ribbon.listOfServers", "localhost:7001"); LOG.info("Initializing ApplicationServiceClient"); final ApplicationServiceClient appClient = ApplicationServiceClient.getInstance(); final Application app1 = appClient.createApplication( ApplicationServiceSampleClient.getSampleApplication(ApplicationServiceSampleClient.ID)); LOG.info("Created application:"); LOG.info(app1.toString()); final Application app2 = appClient.createApplication( ApplicationServiceSampleClient.getSampleApplication(ApplicationServiceSampleClient.ID + "2")); LOG.info("Created application:"); LOG.info(app2.toString()); LOG.info("Initializing CommandServiceClient"); final CommandServiceClient commandClient = CommandServiceClient.getInstance(); LOG.info("Creating command pig13_mr2"); final Command command1 = commandClient.createCommand(createSampleCommand(ID)); commandClient.setApplicationForCommand(command1.getId(), app1); LOG.info("Created command:"); LOG.info(command1.toString()); LOG.info("Getting Commands using specified filter criteria name = " + CMD_NAME); final Multimap<String, String> params = ArrayListMultimap.create(); params.put("name", CMD_NAME); final List<Command> commands = commandClient.getCommands(params); if (commands.isEmpty()) { LOG.info("No commands found for specified criteria."); } else { LOG.info("Commands found:"); for (final Command command : commands) { LOG.info(command.toString()); } } LOG.info("Getting command config by id"); final Command command3 = commandClient.getCommand(ID); LOG.info(command3.toString()); LOG.info("Updating existing command config"); command3.setStatus(CommandStatus.INACTIVE); final Command command4 = commandClient.updateCommand(ID, command3); LOG.info(command4.toString()); LOG.info("Configurations for command with id " + command1.getId()); final Set<String> configs = commandClient.getConfigsForCommand(command1.getId()); for (final String config : configs) { LOG.info("Config = " + config); } LOG.info("Adding configurations to command with id " + command1.getId()); final Set<String> newConfigs = new HashSet<>(); newConfigs.add("someNewConfigFile"); newConfigs.add("someOtherNewConfigFile"); final Set<String> configs2 = commandClient.addConfigsToCommand(command1.getId(), newConfigs); for (final String config : configs2) { LOG.info("Config = " + config); } LOG.info("Updating set of configuration files associated with id " + command1.getId()); //This should remove the original config leaving only the two in this set final Set<String> configs3 = commandClient.updateConfigsForCommand(command1.getId(), newConfigs); for (final String config : configs3) { LOG.info("Config = " + config); } LOG.info("Deleting all the configuration files from the command with id " + command1.getId()); //This should remove the original config leaving only the two in this set final Set<String> configs4 = commandClient.removeAllConfigsForCommand(command1.getId()); for (final String config : configs4) { //Shouldn't print anything LOG.info("Config = " + config); } /**************** Begin tests for tag Api's *********************/ LOG.info("Get tags for command with id " + command1.getId()); final Set<String> tags = command1.getTags(); for (final String tag : tags) { LOG.info("Tag = " + tag); } LOG.info("Adding tags to command with id " + command1.getId()); final Set<String> newTags = new HashSet<>(); newTags.add("tag1"); newTags.add("tag2"); final Set<String> tags2 = commandClient.addTagsToCommand(command1.getId(), newTags); for (final String tag : tags2) { LOG.info("Tag = " + tag); } LOG.info("Updating set of tags associated with id " + command1.getId()); //This should remove the original config leaving only the two in this set final Set<String> tags3 = commandClient.updateTagsForCommand(command1.getId(), newTags); for (final String tag : tags3) { LOG.info("Tag = " + tag); } LOG.info("Deleting one tag from the command with id " + command1.getId()); //This should remove the "tag3" from the tags final Set<String> tags5 = commandClient.removeTagForCommand(command1.getId(), "tag1"); for (final String tag : tags5) { //Shouldn't print anything LOG.info("Tag = " + tag); } LOG.info("Deleting all the tags from the command with id " + command1.getId()); //This should remove the original config leaving only the two in this set final Set<String> tags4 = commandClient.removeAllConfigsForCommand(command1.getId()); for (final String tag : tags4) { //Shouldn't print anything LOG.info("Config = " + tag); } /********************** End tests for tag Api's **********************/ LOG.info("Application for command with id " + command1.getId()); final Application application = commandClient.getApplicationForCommand(command1.getId()); LOG.info("Application = " + application); LOG.info("Removing Application for command with id " + command1.getId()); final Application application2 = commandClient.removeApplicationForCommand(command1.getId()); LOG.info("Application = " + application2); LOG.info("Getting all the clusters for command with id " + command1.getId()); final Set<Cluster> clusters = commandClient.getClustersForCommand(command1.getId()); for (final Cluster cluster : clusters) { LOG.info("Cluster = " + cluster); } LOG.info("Deleting command config using id"); final Command command5 = commandClient.deleteCommand(ID); LOG.info("Deleted command config with id: " + ID); LOG.info(command5.toString()); LOG.info("Deleting all applications"); final List<Application> deletedApps = appClient.deleteAllApplications(); LOG.info("Deleted all applications"); LOG.info(deletedApps.toString()); LOG.info("Done"); }
From source file:de.phillme.PhotoSorter.java
public static void main(String[] args) { PhotoConfig photoConfig = new PhotoConfig(); // create the parser CommandLineParser parser = new DefaultParser(); try {/*from w ww . ja v a 2 s.c o m*/ // parse the command line arguments CommandLine line = parser.parse(photoConfig.getOptions(), args); if (line.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("PhotoSorter", photoConfig.getOptions()); return; } PhotoSorter photoSorter = new PhotoSorter(line); List<PhotoFile> photoFileList; List<PhotoFile> sortedList; //photoSorter.probeFiletypes(); photoFileList = photoSorter.listSourceFiles(); sortedList = photoSorter.sortList(photoFileList); LOGGER.finest(sortedList.toString()); photoSorter.flagAllEvents(sortedList); photoSorter.printEventList(photoSorter.getEventList()); //LOGGER.info(pathList.toString()); } catch (org.apache.commons.cli.ParseException e) { LOGGER.severe(e.getMessage()); } catch (IOException e) { LOGGER.severe(e.getMessage()); } catch (ImageProcessingException e) { LOGGER.severe(e.getMessage()); } }
From source file:hydrograph.server.execution.tracking.client.main.HydrographMain.java
/** * The main method.//w ww . j a v a 2 s . c o m * * @param args * the arguments * @throws Exception * the exception */ public static void main(String[] args) throws Exception { HydrographMain hydrographMain = new HydrographMain(); final Timer timer = new Timer(); final CountDownLatch latch = new CountDownLatch(1); try { Session session = null; boolean isExecutionTracking = false; String[] argsList = args; List<String> argumentList = new ArrayList<String>(Arrays.asList(args)); final String jobId = hydrographMain.getJobId(argumentList); getLogLevel(argumentList).ifPresent(x -> { if (!x.equalsIgnoreCase(String.valueOf(logger.getLevel()))) { setLoglevel(x); } else { Optional.empty(); } }); logger.info("Argument List: " + argumentList.toString()); String trackingClientSocketPort = hydrographMain.getTrackingClientSocketPort(argumentList); if (argumentList.contains(Constants.IS_TRACKING_ENABLE)) { int index = argumentList.indexOf(Constants.IS_TRACKING_ENABLE); isExecutionTracking = Boolean.valueOf(argsList[index + 1]); argumentList = removeItemFromIndex(index, argumentList); } if (argumentList.contains(Constants.TRACKING_CLIENT_SOCKET_PORT)) { int index = argumentList.indexOf(Constants.TRACKING_CLIENT_SOCKET_PORT); argumentList = removeItemFromIndex(index, argumentList); } argsList = argumentList.toArray(new String[argumentList.size()]); logger.debug("Execution tracking enabled - " + isExecutionTracking); logger.info("Tracking Client Port: " + trackingClientSocketPort); /** * Start new thread to run job */ final HydrographService execution = new HydrographService(); FutureTask task = hydrographMain.executeGraph(latch, jobId, argsList, execution, isExecutionTracking); hydrographMain.executorService = Executors.newSingleThreadExecutor(); hydrographMain.executorService.submit(task); if (isExecutionTracking) { //If tracking is enabled, start to post execution tracking status. final HydrographEngineCommunicatorSocket socket = new HydrographEngineCommunicatorSocket(execution); session = hydrographMain.connectToServer(socket, jobId, trackingClientSocketPort); hydrographMain.sendExecutionTrackingStatus(latch, session, jobId, timer, execution, socket); } //waiting for execute graph thread task.get(); } catch (Exception exp) { logger.info("Getting exception from HydrographMain"); throw new RuntimeException(exp); } finally { //cleanup threads --> executor thread and timer thread logger.info("HydrographMain releasing resources"); if (!hydrographMain.executorService.isShutdown() && !hydrographMain.executorService.isTerminated()) { hydrographMain.executorService.shutdown(); } timer.cancel(); } }
From source file:fmiquerytest.Coordinates.java
public static void main(String[] args) { df_short.setTimeZone(tz); df_iso.setTimeZone(tz);// w ww. ja va 2 s . com df_daycode.setTimeZone(tz); DecimalFormatSymbols otherSymbols = new DecimalFormatSymbols(); otherSymbols.setDecimalSeparator('.'); df_fiveDecimal.setDecimalFormatSymbols(otherSymbols); String startTime = df_short.format(new Date(startTimeMillis)); System.out.println("startTime: " + startTime); //Clean up old weather data //********************************************************************** FileSystemTools.cleanupOldWeatherData(daysToStoreWeatherData); //Google query //********************************************************************** if (gShare.equals("")) { Scanner input = new Scanner(System.in); System.out.println("Paste Google Directions Share:"); gShare = input.nextLine(); } String gQuery = Parser.getQueryFromShare(gShare); System.out.println("Google query URL: " + gQuery); //Check if we already have this route //Valid only if the route option is 0 (default) //Because otherwise we cannot be sure we already have the optional route List<routeStep> gSteps = new ArrayList<>(); if (FileSystemTools.isSavedRoute(gQuery) && gRouteOption == 0) { System.out.println("Route found from saved list. Loading."); gSteps = FileSystemTools.loadSavedRoute(gQuery); } else { gSteps = Parser.getSteps(gQuery); if (gRouteOption == 0) { System.out.println("Saving new route to list."); FileSystemTools.saveRoute(gQuery, gSteps); } } //Compile route table with current settings //********************************************************************** List<routeStep> routeData = RouteTools.compileRoute(gSteps, refreshInterval); String endTime = df_short.format(new Date(startTimeMillis + routeDur * 1000)); System.out.println("endTime: " + endTime); //Forecast from FMI is only for 48h - warning if we are going over //Or is it 54h? http://ilmatieteenlaitos.fi/avoin-data-saaennustedata-hirlam if (((startTimeMillis + routeDur * 1000) - System.currentTimeMillis()) / (1000 * 60 * 60) > 48) { System.out.println("**************************************************" + newLine + "WARNING:" + newLine + "Weather forecast available only for 48 hours" + newLine + "**************************************************"); } //Prepare time and file variables //********************************************************************** String nowAsISO = df_iso.format(new Date()); System.out.println("Start ISO time: " + nowAsISO); double timeMarginal = routeDur * 1.2 + 3600; String endTimeForFmi = df_iso.format(new Date(startTimeMillis + (intValue(timeMarginal)) * 1000)); String endTimeForFile = df_iso.format(new Date(startTimeMillis + (intValue(routeDur + 3600)) * 1000)); System.out.println("End ISO time: " + endTimeForFmi); String fmiParam = new StringBuilder("&starttime=").append(nowAsISO).append("&endtime=") .append(endTimeForFmi).toString(); File weatherDataFileNameFirst = new File("weather" + nowAsISO.replaceAll("[^A-Za-z0-9 ]", "") + ".txt"); File weatherDataFileNameLast = new File("weather" + endTimeForFmi.replaceAll("[^A-Za-z0-9 ]", "") + ".txt"); File weatherDataFileNameStart = new File( "weather" + (df_iso.format(new Date(startTimeMillis))).replaceAll("[^A-Za-z0-9 ]", "") + ".txt"); File weatherDataFileNameEnd = new File("weather" + endTimeForFile.replaceAll("[^A-Za-z0-9 ]", "") + ".txt"); List<stationData> allStations = new ArrayList<>(); List<stationData> fmiData = new ArrayList<>(); List<String> savedFileTimes = new ArrayList<>(); //********************************************************************** //Check if we already have the weather data //********************************************************************** if (!weatherDataFileNameStart.exists() || !weatherDataFileNameEnd.exists()) { //FMI query //********************************************************************** String fmiCities = new StringBuilder(fmiBase).append(fmiKey).append(fmiMiddle).append(fmiQueryCities) .append(fmiParam).toString(); String fmiObsStations = new StringBuilder(fmiBase).append(fmiKey).append(fmiMiddle) .append(fmiQueryObsStations).append(fmiParam).toString(); //System.out.println("FMI cities URL: "+fmiCities); //System.out.println("FMI obsstations URL: "+fmiObsStations); //Collect weather data from FMI //********************************************************************** System.out.print("FMI data:" + newLine + fmiCities + newLine + "Loading and processing..."); fmiData.addAll(Parser.getStations(fmiCities)); System.out.println("SUCCESS."); System.out.print("FMI data:" + newLine + fmiObsStations + newLine + "Loading and processing..."); fmiData.addAll(Parser.getStations(fmiObsStations)); System.out.println("SUCCESS."); //Get unique stations //********************************************************************** List<stationData> uniqueStations = ToolBox.getUniqueStations(fmiData); System.out.println("Parsed stations count: " + uniqueStations.size()); //Save or load stations //********************************************************************** List<stationData> savedStations = new ArrayList<>(); if (!stationFileName.exists()) { //Save current parsed stations to file FileSystemTools.saveObjectToFile(uniqueStations, stationFileName); } else { //Or if the stations were already saved, load them System.out.println("Station information file found: " + stationFileName); System.out.print("Loading..."); savedStations = FileSystemTools.loadStationsFromFile(stationFileName); System.out.println("DONE."); System.out.println("Loaded stations count: " + savedStations.size()); } //Merge station information //********************************************************************** System.out.println("Merging station information."); savedStations.addAll(uniqueStations); allStations = ToolBox.getUniqueStations(savedStations); System.out.println("Merged stations count: " + allStations.size()); //Find names for stations //********************************************************************** String gMapsGeoCode = "https://maps.googleapis.com/maps/api/geocode/xml?latlng="; //for (stationData station : allStations){ for (int i = 0; i < allStations.size(); i++) { if (allStations.get(i).stationName.equals("")) { gQuery = new StringBuilder(gMapsGeoCode).append(allStations.get(i).stationLocation.Lat) .append(",").append(allStations.get(i).stationLocation.Lon).append("&key=").append(gKey) .toString(); System.out.println("Google query URL: " + gQuery); allStations.get(i).stationName = Parser.getStationName(gQuery); } } //System.out.println("Station names parsed."); Collections.sort(allStations); //Print stations and separate them for saving //********************************************************************** List<stationData> onlyStations = new ArrayList<>(); //int indeksi = 0; List<weatherData> weatherPoint = new ArrayList<>(); weatherPoint.add(0, new weatherData("", "", "")); for (stationData station : allStations) { //System.out.format("%-4s%-30s%-10s%-10s%n", // indeksi,station.stationName,station.stationLocation.Lat,station.stationLocation.Lon); //++indeksi; onlyStations.add(new stationData(station.stationLocation, station.stationName, weatherPoint)); } //Save station names //********************************************************************** System.out.println("Saving station names."); FileSystemTools.saveObjectToFile(onlyStations, stationFileName); //Save weather dataset //********************************************************************** //Compute file names between start and end System.out.println("Saving weather data..."); long currentTimeAsDouble = System.currentTimeMillis(); int hoursPassed = intValue(Math.floor(currentTimeAsDouble - startTimeMillis) / 1000 / 60 / 60); File weatherDataFileNameTemp = weatherDataFileNameFirst; while (!weatherDataFileNameTemp.equals(weatherDataFileNameLast)) { String savedFileTime = df_iso.format(new Date(startTimeMillis + ((hoursPassed * 3600) * 1000))); savedFileTimes.add(savedFileTime); weatherDataFileNameTemp = new File( "weather" + savedFileTime.replaceAll("[^A-Za-z0-9 ]", "") + ".txt"); //System.out.println("Weather data file: "+weatherDataFileNameTemp); //This if we don't actually maybe want //if (!weatherDataFileNameTemp.exists()){ List<stationData> thisHourWeather = FileSystemTools.extractHourOfWeatherData(savedFileTime, fmiData); //System.out.println("Saving: "+weatherDataFileNameTemp); FileSystemTools.saveObjectToFile(thisHourWeather, weatherDataFileNameTemp); //} ++hoursPassed; } } //If we have weather data saved, definitely we have the stations also //********************************************************************** else { System.out.println("Loading weather data..."); File weatherDataFileNameTemp = weatherDataFileNameStart; int hoursPassed = 0; while (!weatherDataFileNameTemp.equals(weatherDataFileNameEnd)) { String savedFileTime = df_iso.format(new Date(startTimeMillis + ((hoursPassed * 3600) * 1000))); savedFileTimes.add(savedFileTime); weatherDataFileNameTemp = new File( "weather" + savedFileTime.replaceAll("[^A-Za-z0-9 ]", "") + ".txt"); System.out.println("Weather data file: " + weatherDataFileNameTemp); if (weatherDataFileNameTemp.exists()) { fmiData.addAll(FileSystemTools.loadStationsFromFile(weatherDataFileNameTemp)); } ++hoursPassed; } allStations = FileSystemTools.loadStationsFromFile(stationFileName); System.out.println("DONE."); } //Find closest weather stations in route points and extract their data //********************************************************************** System.out.println("Calculating nearest stations in route points:"); List<Integer> neededStations = new ArrayList<>(); for (routeStep step : routeData) { distance[] stationDistances = RouteTools.calculateStationDistances(step.StartLocation, allStations); System.out.format("%-6s%.5f, %.5f ", "Step: ", step.StartLocation.Lat, step.StartLocation.Lon); for (int i = 0; i < 1; i++) { System.out.format("%-9s%-5s%-20s%.5f%n", "Station: ", stationDistances[i].stationNum, allStations.get(stationDistances[i].stationNum).stationName, stationDistances[i].stationDistance); } neededStations.add(stationDistances[0].stationNum); } System.out.println("Needed stations: " + neededStations.toString().trim()); //Remove duplicates from needed stations list Set<Integer> uniqueEntries = new HashSet<Integer>(neededStations); //Extract weather data from needed stations Map routeWeather = Collections.synchronizedMap(new HashMap()); routeWeather = WeatherTools.extractNeededStations(uniqueEntries, fmiData, allStations); //Find what fields we have List<String> allParameters = new ArrayList<>(); for (int i = 0; i < fmiData.size(); ++i) { allParameters.add(fmiData.get(i).weatherData.get(0).parameterName); } Set<String> uniqueParameters = new HashSet<String>(allParameters); for (String par : uniqueParameters) { for (Integer num : uniqueEntries) { for (String time : savedFileTimes) { //System.out.format("%-5s%-25s%-35s%s%n",num,time,par,routeWeather.get(num+"-"+time+"-"+par)); } } } // Build the final data table //********************************************************************** List<stepWeather> stepDataBase = new ArrayList<>(); stepDataBase = RouteTools.combineRouteDatabase(routeData, neededStations, allStations); //Find sunrise and sunset times during the route //********************************************************************** List<String> sunEvents = DayLightTime.calculateSunEvents(stepDataBase); for (String s : sunEvents) { System.out.println(s.replaceAll(",", ".")); } //Make a webpage to show the weather data //********************************************************************** WeatherTools.makeResultHtml(stepDataBase, allStations, routeWeather, sunEvents); }
From source file:com.music.Generator.java
public static void main(String[] args) throws Exception { Score score1 = new Score(); Read.midi(score1, "c:/tmp/gen.midi"); for (Part part : score1.getPartArray()) { System.out.println(part.getInstrument()); }/*from www . j a va2s .c o m*/ new StartupListener().contextInitialized(null); Generator generator = new Generator(); generator.configLocation = "c:/config/music"; generator.maxConcurrentGenerations = 5; generator.init(); UserPreferences prefs = new UserPreferences(); prefs.setElectronic(Ternary.YES); //prefs.setSimpleMotif(Ternary.YES); //prefs.setMood(Mood.MAJOR); //prefs.setDrums(Ternary.YES); //prefs.setClassical(true); prefs.setAccompaniment(Ternary.YES); prefs.setElectronic(Ternary.YES); final ScoreContext ctx = generator.generatePiece(); Score score = ctx.getScore(); for (Part part : score.getPartArray()) { System.out.println(part.getTitle() + ": " + part.getInstrument()); } System.out.println("Metre: " + ctx.getMetre()[0] + "/" + ctx.getMetre()[1]); System.out.println(ctx); Write.midi(score, "c:/tmp/gen.midi"); new Thread(new Runnable() { @Override public void run() { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setBounds(0, 0, 500, 500); frame.setVisible(true); Part part = ctx.getParts().get(PartType.MAIN); Note[] notes = part.getPhrase(0).getNoteArray(); List<Integer> pitches = new ArrayList<Integer>(); for (Note note : notes) { if (!note.isRest()) { pitches.add(note.getPitch()); } } GraphicsPanel gp = new GraphicsPanel(pitches); frame.setContentPane(gp); } }).start(); DecimalFormat df = new DecimalFormat("#.##"); for (Part part : score.getPartArray()) { StringBuilder sb = new StringBuilder(); printStatistics(ctx, part); System.out.println("------------ " + part.getTitle() + "-----------------"); Phrase[] phrases = part.getPhraseArray(); for (Phrase phr : phrases) { if (phr instanceof ExtendedPhrase) { sb.append("Contour=" + ((ExtendedPhrase) phr).getContour() + " "); } double measureSize = 0; int measures = 0; double totalLength = 0; List<String> pitches = new ArrayList<String>(); List<String> lengths = new ArrayList<String>(); System.out.println("((Phrase notes: " + phr.getNoteArray().length + ")"); for (Note note : phr.getNoteArray()) { if (!note.isRest()) { int degree = 0; if (phr instanceof ExtendedPhrase) { degree = Arrays.binarySearch(((ExtendedPhrase) phr).getScale().getDefinition(), note.getPitch() % 12); } pitches.add(String.valueOf(note.getPitch() + " (" + degree + ") ")); } else { pitches.add(" R "); } lengths.add(df.format(note.getRhythmValue())); measureSize += note.getRhythmValue(); totalLength += note.getRhythmValue(); ; if (measureSize >= ctx.getNormalizedMeasureSize()) { pitches.add(" || "); lengths.add(" || " + (measureSize > ctx.getNormalizedMeasureSize() ? "!" : "")); measureSize = 0; measures++; } } sb.append(pitches.toString() + "\r\n"); sb.append(lengths.toString() + "\r\n"); if (part.getTitle().equals(PartType.MAIN.getTitle())) { sb.append("\r\n"); } System.out.println("Phrase measures: " + measures); System.out.println("Phrase length: " + totalLength); } System.out.println(sb.toString()); } MutingPrintStream.ignore.set(true); Write.midi(score, "c:/tmp/gen.midi"); MutingPrintStream.ignore.set(null); Play.midi(score); generator.toMp3(FileUtils.readFileToByteArray(new File("c:/tmp/gen.midi"))); }
From source file:com.intelius.iap4.TigerLineHit.java
public static void main(String[] args) { String _tigerDs = "jdbc:h2:/home/sxu/playground/tiger"; ResultSet rs = null;/*from w w w . j a v a 2 s . c o m*/ PreparedStatement ps = null; List<TigerLineHit> ret = new ArrayList<TigerLineHit>(); try { // if (_tigerDs instanceof JdbcDataSource) { // JdbcDataSource ds = (JdbcDataSource) _tigerDs; // conn = ds.getPooledConnection().getConnection(); // }else{ // conn = _tigerDs.getConnection(); // } //try address "540 westerly parkway, state college, pa 16801" Class.forName("org.h2.Driver"); Connection conn = DriverManager.getConnection(_tigerDs, "sa", ""); ps = conn.prepareStatement(generateSelectQuery("PA")); int i = 1; String streetNum = "540"; String zip = "16801"; ps.setString(i++, "Westerly"); ps.setString(i++, streetNum); ps.setString(i++, streetNum); ps.setString(i++, streetNum); ps.setString(i++, streetNum); ps.setString(i++, streetNum); ps.setString(i++, streetNum); ps.setString(i++, streetNum); ps.setString(i++, streetNum); ps.setString(i++, zip); ps.setString(i++, zip); rs = ps.executeQuery(); while (rs.next()) { TigerLineHit hit = new TigerLineHit(); hit.streetNum = streetNum; hit.tlid = rs.getLong("tlid"); hit.frAddL = rs.getString("fraddl"); hit.frAddR = rs.getString("fraddr"); hit.toAddL = rs.getString("toaddl"); hit.toAddR = rs.getString("toaddr"); hit.zipL = rs.getString("zipL"); hit.zipR = rs.getString("zipR"); hit.toLat = rs.getFloat("tolat"); hit.toLon = rs.getFloat("tolong"); hit.frLat = rs.getFloat("frlat"); hit.frLon = rs.getFloat("tolong"); hit.lat1 = rs.getFloat("lat1"); hit.lat2 = rs.getFloat("lat2"); hit.lat3 = rs.getFloat("lat3"); hit.lat4 = rs.getFloat("lat4"); hit.lat5 = rs.getFloat("lat5"); hit.lat6 = rs.getFloat("lat6"); hit.lat7 = rs.getFloat("lat7"); hit.lat8 = rs.getFloat("lat8"); hit.lat9 = rs.getFloat("lat9"); hit.lat10 = rs.getFloat("lat10"); hit.lon1 = rs.getFloat("long1"); hit.lon2 = rs.getFloat("long2"); hit.lon3 = rs.getFloat("long3"); hit.lon4 = rs.getFloat("long4"); hit.lon5 = rs.getFloat("long5"); hit.lon6 = rs.getFloat("long6"); hit.lon7 = rs.getFloat("long7"); hit.lon8 = rs.getFloat("long8"); hit.lon9 = rs.getFloat("long9"); hit.lon10 = rs.getFloat("long10"); hit.fedirp = rs.getString("fedirp"); hit.fetype = rs.getString("fetype"); hit.fedirs = rs.getString("fedirs"); ret.add(hit); // System.out.println(ret.toString()); // } } catch (Exception e) { e.printStackTrace(); } finally { //DbUtils.closeQuietly(conn); DbUtils.closeQuietly(rs); DbUtils.closeQuietly(ps); } //return ret; }
From source file:Main.java
/** * Prints the elements of a string list without leading and ending brackets. * /*from w w w . j av a 2 s. c om*/ * @param listToPrint * the list to print. * @return a string as a list of elements without leading and ending * brackets. */ public static String printStringList(List<String> listToPrint) { return listToPrint.toString().replace("[", "").replace("]", "").trim(); }
From source file:Main.java
public static String doDraw(String cardName[], int length) { List<String> cardList = Arrays.asList(cardName); Collections.shuffle(cardList); return cardList.toString(); }