• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FormatterClosedException类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中java.util.FormatterClosedException的典型用法代码示例。如果您正苦于以下问题:Java FormatterClosedException类的具体用法?Java FormatterClosedException怎么用?Java FormatterClosedException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FormatterClosedException类属于java.util包,在下文中一共展示了FormatterClosedException类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getString

import java.util.FormatterClosedException; //导入依赖的package包/类
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;
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:19,代码来源:ResManager.java


示例2: composeHeapStatus

import java.util.FormatterClosedException; //导入依赖的package包/类
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;
}
 
开发者ID:tonight-halfmoon,项目名称:Vaadin-Prime-Count,代码行数:17,代码来源:HeapStatusSimpleProvider.java


示例3: test_flush

import java.util.FormatterClosedException; //导入依赖的package包/类
/**
 * @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();
}
 
开发者ID:shannah,项目名称:cn1,代码行数:21,代码来源:FormatterTest.java


示例4: addRecords

import java.util.FormatterClosedException; //导入依赖的package包/类
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("? ");
   }
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:30,代码来源:CreateTextFile.java


示例5: getString

import java.util.FormatterClosedException; //导入依赖的package包/类
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;
}
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:16,代码来源:ResManager.java


示例6: test_locale

import java.util.FormatterClosedException; //导入依赖的package包/类
/**
 * @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
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:17,代码来源:FormatterTest.java


示例7: test_out

import java.util.FormatterClosedException; //导入依赖的package包/类
/**
 * @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
    }

}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:FormatterTest.java


示例8: test_toString

import java.util.FormatterClosedException; //导入依赖的package包/类
/**
 * @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
    }
}
 
开发者ID:shannah,项目名称:cn1,代码行数:16,代码来源:FormatterTest.java


示例9: ensureOpen

import java.util.FormatterClosedException; //导入依赖的package包/类
private void ensureOpen() {
    if (a == null)
        throw new FormatterClosedException();
}
 
开发者ID:unktomi,项目名称:form-follows-function,代码行数:5,代码来源:F3Formatter.java


示例10: testSerializationSelf

import java.util.FormatterClosedException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization.
 */
public void testSerializationSelf() throws Exception {

    SerializationTest.verifySelf(new FormatterClosedException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:8,代码来源:FormatterClosedExceptionTest.java


示例11: testSerializationCompatibility

import java.util.FormatterClosedException; //导入依赖的package包/类
/**
 * @tests serialization/deserialization compatibility with RI.
 */
public void testSerializationCompatibility() throws Exception {

    SerializationTest.verifyGolden(this, new FormatterClosedException());
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:8,代码来源:FormatterClosedExceptionTest.java


示例12: addRecords

import java.util.FormatterClosedException; //导入依赖的package包/类
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
}
 
开发者ID:meisamhe,项目名称:GPLshared,代码行数:56,代码来源:CreateTextFile.java



注:本文中的java.util.FormatterClosedException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OWLReasonerFactory类代码示例发布时间:2022-05-21
下一篇:
Java UnsyncBufferedOutputStream类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap