Java 类java.util.FormatterClosedException 实例源码

项目:LuoYing    文件:ResManager.java   
private String getString(Map<String, String> resource, String key, Object[] params) {
    if (resource == null) {
        return "<" + key + ">";
    }
    String value = resource.get(key);
    if (value == null) {
        value = "<" + key + ">";
    }
    if (params != null) {
        try {
            value = String.format(value, params);
        } catch (FormatterClosedException fce) {
            LOG.log(Level.WARNING, fce.getMessage(), fce);
            value = "<" + key + ">";
        }
    }
    return value;
}
项目:Vaadin-Prime-Count    文件:HeapStatusSimpleProvider.java   
private static String composeHeapStatus(final long... memoryStatus)
{
    final StringBuilder strBldr = new StringBuilder();
    strBldr.append("%d M of %d M"); //NOPMD
    String output = Constants.EMPTY; //NOPMD
    try (final Formatter formatter = new Formatter(Locale.UK);)
    {
        formatter.format(strBldr.toString(), memoryStatus[0], memoryStatus[1]); //NOPMD
        output = formatter.toString(); //NOPMD
    }
    catch (IllegalFormatException | FormatterClosedException e)
    {
        LoggerFactory.getLogger(HeapStatusSimpleProvider.class).error("Error while composing Heap status ", e); //NOPMD
    }
    return output;
}
项目:cn1    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#flush()
 */
public void test_flush() throws IOException {
    Formatter f = null;
    f = new Formatter(notExist);
    assertTrue(f instanceof Flushable);
    f.close();
    try {
        f.flush();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }

    f = new Formatter();
    // For destination that does not implement Flushable
    // No exception should be thrown
    f.flush();
}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#flush()
 */
public void test_flush() throws IOException {
    Formatter f = null;
    f = new Formatter(notExist);
    assertTrue(f instanceof Flushable);
    f.close();
    try {
        f.flush();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }

    f = new Formatter();
    // For destination that does not implement Flushable
    // No exception should be thrown
    f.flush();
}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#flush()
 */
public void test_flush() throws IOException {
    Formatter f = null;
    f = new Formatter(notExist);
    assertTrue(f instanceof Flushable);
    f.close();
    try {
        f.flush();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }

    f = new Formatter();
    // For destination that does not implement Flushable
    // No exception should be thrown
    f.flush();
}
项目:LivroJavaComoProgramar10Edicao    文件:CreateTextFile.java   
public static void addRecords()
{
   Scanner input = new Scanner(System.in);
   System.out.printf("%s%n%s%n? ", 
      "Enter account number, first name, last name and balance.",
      "Enter end-of-file indicator to end input.");

   while (input.hasNext()) // loop until end-of-file indicator
   {
      try
      {
         // output new record to file; assumes valid input
         output.format("%d %s %s %.2f%n", input.nextInt(),
            input.next(), input.next(), input.nextDouble());                             
      } 
      catch (FormatterClosedException formatterClosedException)
      {
         System.err.println("Error writing to file. Terminating.");
         break;
      } 
      catch (NoSuchElementException elementException)
      {
         System.err.println("Invalid input. Please try again.");
         input.nextLine(); // discard input so user can try again
      } 

      System.out.print("? ");
   }
}
项目:LuoYing    文件:ResManager.java   
private static String getString(Map<String, String> resource, String key, Object[] params) {
    String value = resource.get(key);
    if (value == null) {
        value = "<" + key + ">";
    }
    if (params != null) {
        try {
            value = String.format(value, params);
        } catch (FormatterClosedException fce) {
            LOG.log(Level.WARNING, fce.getMessage(), fce);
            value = "<" + key + ">";
        }
    }
    return value;
}
项目:cn1    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#locale()
 */
public void test_locale() {
    Formatter f = null;
    f = new Formatter((Locale) null);
    assertNull(f.locale());

    f.close();
    try {
        f.locale();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }
}
项目:cn1    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#out()
 */
public void test_out() {
    Formatter f = null;
    f = new Formatter();
    assertNotNull(f.out());
    assertTrue(f.out() instanceof StringBuilder);
    f.close();
    try {
        f.out();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }

}
项目:cn1    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#toString()
 */
public void test_toString() {
    Formatter f = new Formatter();
    assertNotNull(f.toString());
    assertEquals(f.out().toString(), f.toString());
    f.close();
    try {
        f.toString();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }
}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#locale()
 */
public void test_locale() {
    Formatter f = null;
    f = new Formatter((Locale) null);
    assertNull(f.locale());

    f.close();
    try {
        f.locale();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }
}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#out()
 */
public void test_out() {
    Formatter f = null;
    f = new Formatter();
    assertNotNull(f.out());
    assertTrue(f.out() instanceof StringBuilder);
    f.close();
    try {
        f.out();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }

}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#toString()
 */
public void test_toString() {
    Formatter f = new Formatter();
    assertNotNull(f.toString());
    assertEquals(f.out().toString(), f.toString());
    f.close();
    try {
        f.toString();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }
}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#locale()
 */
public void test_locale() {
    Formatter f = null;
    f = new Formatter((Locale) null);
    assertNull(f.locale());

    f.close();
    try {
        f.locale();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }
}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#out()
 */
public void test_out() {
    Formatter f = null;
    f = new Formatter();
    assertNotNull(f.out());
    assertTrue(f.out() instanceof StringBuilder);
    f.close();
    try {
        f.out();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }

}
项目:freeVM    文件:FormatterTest.java   
/**
 * @tests java.util.Formatter#toString()
 */
public void test_toString() {
    Formatter f = new Formatter();
    assertNotNull(f.toString());
    assertEquals(f.out().toString(), f.toString());
    f.close();
    try {
        f.toString();
        fail("should throw FormatterClosedException");
    } catch (FormatterClosedException e) {
        // expected
    }
}
项目:form-follows-function    文件:F3Formatter.java   
private void ensureOpen() {
    if (a == null)
        throw new FormatterClosedException();
}
项目:In-the-Box-Fork    文件:FormatterClosedExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FormatterClosedException());
}
项目:In-the-Box-Fork    文件:FormatterClosedExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new FormatterClosedException());
}
项目:GPLshared    文件:CreateTextFile.java   
public void addRecords()
{
   // object to be written to file
   AccountRecord record = new AccountRecord();

   Scanner input = new Scanner( System.in );

   System.out.printf( "%s\n%s\n%s\n%s\n\n",
      "To terminate input, type the end-of-file indicator ",
      "when you are prompted to enter input.",
      "On UNIX/Linux/Mac OS X type <ctrl> d then press Enter",
      "On Windows type <ctrl> z then press Enter" );

   System.out.printf( "%s\n%s", 
      "Enter account number (> 0), first name, last name and balance.",
      "? " );

   while ( input.hasNext() ) // loop until end-of-file indicator
   {
      try // output values to file
      {
         // retrieve data to be output
         record.setAccount( input.nextInt() ); // read account number
         record.setFirstName( input.next() ); // read first name
         record.setLastName( input.next() ); // read last name
         record.setBalance( input.nextDouble() ); // read balance

         if ( record.getAccount() > 0 )
         {
            // write new record
            output.format( "%d %s %s %.2f\n", record.getAccount(), 
               record.getFirstName(), record.getLastName(),
               record.getBalance() );
         } // end if
         else
         {
            System.out.println(
               "Account number must be greater than 0." );
         } // end else
      } // end try
      catch ( FormatterClosedException formatterClosedException )
      {
         System.err.println( "Error writing to file." );
         return;
      } // end catch
      catch ( NoSuchElementException elementException )
      {
         System.err.println( "Invalid input. Please try again." );
         input.nextLine(); // discard input so user can try again
      } // end catch

      System.out.printf( "%s %s\n%s", "Enter account number (>0),",
         "first name, last name and balance.", "? " );
   } // end while
}
项目:cn1    文件:FormatterClosedExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FormatterClosedException());
}
项目:cn1    文件:FormatterClosedExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new FormatterClosedException());
}
项目:freeVM    文件:FormatterClosedExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FormatterClosedException());
}
项目:freeVM    文件:FormatterClosedExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new FormatterClosedException());
}
项目:freeVM    文件:FormatterClosedExceptionTest.java   
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FormatterClosedException());
}
项目:freeVM    文件:FormatterClosedExceptionTest.java   
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new FormatterClosedException());
}