@Test public void testProcessCsv() throws Exception { assertEquals(outputFile.length(), 0); example.processCsv(Shared.getGoodUserAgentsFile(), outputFile.getAbsolutePath()); assertNotEquals(outputFile.length(), 0); }
public void processCsv(String inputFileName, String outputFilename) throws IOException { BufferedReader bufferedReader = new BufferedReader(new FileReader(inputFileName)); try { FileWriter fileWriter = new FileWriter(outputFilename); try { Match match = provider.createMatch(); for (int i = 0; i < 20; i++) { String userAgentString = bufferedReader.readLine(); provider.match(userAgentString, match); Values isMobile = match.getValues("IsMobile"); Values platformName = match.getValues("PlatformName"); Values platformVersion = match.getValues("PlatformVersion"); fileWriter.append("\"") .append(userAgentString) .append("\", ") .append(getValueForDisplay(isMobile)) .append(", ") .append(getValueForDisplay(platformName)) .append(", ") .append(getValueForDisplay(platformVersion)) .append('\n') .flush(); } } finally { fileWriter.close(); } } finally { bufferedReader.close(); } }
OfflineProcessingExample implements Closeable { public void processCsv(String inputFileName, String outputFilename) throws IOException { BufferedReader bufferedReader = new BufferedReader(new FileReader(inputFileName)); try { FileWriter fileWriter = new FileWriter(outputFilename); try { Match match = provider.createMatch(); for (int i = 0; i < 20; i++) { String userAgentString = bufferedReader.readLine(); provider.match(userAgentString, match); Values isMobile = match.getValues("IsMobile"); Values platformName = match.getValues("PlatformName"); Values platformVersion = match.getValues("PlatformVersion"); fileWriter.append("\"") .append(userAgentString) .append("\", ") .append(getValueForDisplay(isMobile)) .append(", ") .append(getValueForDisplay(platformName)) .append(", ") .append(getValueForDisplay(platformVersion)) .append('\n') .flush(); } } finally { fileWriter.close(); } } finally { bufferedReader.close(); } } }
OfflineProcessingExample implements Closeable { public void processCsv(String inputFileName, String outputFilename) throws IOException { BufferedReader bufferedReader = new BufferedReader(new FileReader(inputFileName)); try { FileWriter fileWriter = new FileWriter(outputFilename); try { Match match = provider.createMatch(); for (int i = 0; i < 20; i++) { String userAgentString = bufferedReader.readLine(); provider.match(userAgentString, match); Values isMobile = match.getValues("IsMobile"); Values platformName = match.getValues("PlatformName"); Values platformVersion = match.getValues("PlatformVersion"); fileWriter.append("\"") .append(userAgentString) .append("\", ") .append(getValueForDisplay(isMobile)) .append(", ") .append(getValueForDisplay(platformName)) .append(", ") .append(getValueForDisplay(platformVersion)) .append('\n') .flush(); } } finally { fileWriter.close(); } } finally { bufferedReader.close(); } } OfflineProcessingExample(); }
OfflineProcessingExample implements Closeable { public void processCsv(String inputFileName, String outputFilename) throws IOException { BufferedReader bufferedReader = new BufferedReader(new FileReader(inputFileName)); try { FileWriter fileWriter = new FileWriter(outputFilename); try { Match match = provider.createMatch(); for (int i = 0; i < 20; i++) { String userAgentString = bufferedReader.readLine(); provider.match(userAgentString, match); Values isMobile = match.getValues("IsMobile"); Values platformName = match.getValues("PlatformName"); Values platformVersion = match.getValues("PlatformVersion"); fileWriter.append("\"") .append(userAgentString) .append("\", ") .append(getValueForDisplay(isMobile)) .append(", ") .append(getValueForDisplay(platformName)) .append(", ") .append(getValueForDisplay(platformVersion)) .append('\n') .flush(); } } finally { fileWriter.close(); } } finally { bufferedReader.close(); } } OfflineProcessingExample(); void processCsv(String inputFileName, String outputFilename); @Override void close(); static void main(String[] args); }
OfflineProcessingExample implements Closeable { public void processCsv(String inputFileName, String outputFilename) throws IOException { BufferedReader bufferedReader = new BufferedReader(new FileReader(inputFileName)); try { FileWriter fileWriter = new FileWriter(outputFilename); try { Match match = provider.createMatch(); for (int i = 0; i < 20; i++) { String userAgentString = bufferedReader.readLine(); provider.match(userAgentString, match); Values isMobile = match.getValues("IsMobile"); Values platformName = match.getValues("PlatformName"); Values platformVersion = match.getValues("PlatformVersion"); fileWriter.append("\"") .append(userAgentString) .append("\", ") .append(getValueForDisplay(isMobile)) .append(", ") .append(getValueForDisplay(platformName)) .append(", ") .append(getValueForDisplay(platformVersion)) .append('\n') .flush(); } } finally { fileWriter.close(); } } finally { bufferedReader.close(); } } OfflineProcessingExample(); void processCsv(String inputFileName, String outputFilename); @Override void close(); static void main(String[] args); public String outputFilePath; }