当前位置: 首页>>代码示例>>Java>>正文


Java IO类代码示例

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


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

示例1: NumberValue

import io.advantageous.boon.core.IO; //导入依赖的package包/类
public NumberValue( boolean chop, TypeType type, int startIndex, int endIndex, char[] buffer ) {
    this.type = type;


    try {
        if ( chop ) {

            this.buffer = Arrays.copyOfRange ( buffer, startIndex, endIndex );
            this.startIndex = 0;
            this.endIndex = this.buffer.length;
            chopped = true;
        } else {
            this.startIndex = startIndex;
            this.endIndex = endIndex;
            this.buffer = buffer;
        }
    } catch ( Exception ex ) {
        IO.puts("exception", ex, "start", startIndex, "end", endIndex);
        Exceptions.handle(ex);

    }
}
 
开发者ID:advantageous,项目名称:boon,代码行数:23,代码来源:NumberValue.java

示例2: getWebPageContents

import io.advantageous.boon.core.IO; //导入依赖的package包/类
public String getWebPageContents() {

        if (webPageContents == null || webPageContents.isEmpty()) {

            final String htmlPageLocationInitial = getHtmlPageLocation();
            final String pageLocation;
            pageLocation = htmlPageLocationInitial.startsWith("/") ?
                    htmlPageLocationInitial.substring(1, htmlPageLocationInitial.length()) :
                    htmlPageLocationInitial;

            webPageContents = IO.read(
                    Thread.currentThread()
                            .getContextClassLoader()
                            .getResourceAsStream(pageLocation)
            );
        }
        return webPageContents;
    }
 
开发者ID:advantageous,项目名称:qbit,代码行数:19,代码来源:AdminBuilder.java

示例3: readBody

import io.advantageous.boon.core.IO; //导入依赖的package包/类
public static String readBody(final HttpServletRequest request) {
    try {
        final ServletInputStream inputStream = request.getInputStream();
        final String read = IO.read(inputStream, StandardCharsets.UTF_8);
        inputStream.close();
        return read;
    } catch (final IOException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:advantageous,项目名称:qbit-extensions,代码行数:11,代码来源:QBitServletUtil.java

示例4: parse

import io.advantageous.boon.core.IO; //导入依赖的package包/类
@Override
public final <T> T parse( Class<T> type, Reader reader ) {

    if (copyBuf==null) {
        copyBuf = new char[bufSize];
    }

    charBuf = IO.read( reader, charBuf, bufSize, copyBuf );
    return parse( type, charBuf.readForRecycle() );

}
 
开发者ID:advantageous,项目名称:boon,代码行数:12,代码来源:JsonMappingParser.java

示例5: parseAsStream

import io.advantageous.boon.core.IO; //导入依赖的package包/类
@Override
public final <T> T parseAsStream( Class<T> type, byte[] value ) {
    if (copyBuf==null) {
        copyBuf = new char[bufSize];
    }

    charBuf = IO.read( new InputStreamReader ( new InMemoryInputStream(value), charset ), charBuf, value.length, copyBuf );
    return this.basicParser.parse ( type, charBuf.readForRecycle () );
}
 
开发者ID:advantageous,项目名称:boon,代码行数:10,代码来源:JsonMappingParser.java

示例6: parse

import io.advantageous.boon.core.IO; //导入依赖的package包/类
@Override
public  Object parse(  Reader reader ) {

    if (copyBuf==null) {
        copyBuf = new char[bufSize];
    }

    fileInputBuf = IO.read ( reader, fileInputBuf, bufSize, copyBuf );
    return parse( fileInputBuf.readForRecycle() );

}
 
开发者ID:advantageous,项目名称:boon,代码行数:12,代码来源:BaseJsonParser.java

示例7: parse

import io.advantageous.boon.core.IO; //导入依赖的package包/类
@Override
public  <T> T parse( Class<T> type, Reader reader ) {

    if (copyBuf==null) {
        copyBuf = new char[bufSize];
    }

    fileInputBuf = IO.read( reader, fileInputBuf, bufSize, copyBuf );
    return parse( type, fileInputBuf.readForRecycle() );

}
 
开发者ID:advantageous,项目名称:boon,代码行数:12,代码来源:BaseJsonParserAndMapper.java

示例8: initializePath

import io.advantageous.boon.core.IO; //导入依赖的package包/类
private void initializePath() {
    String cmd = commandLine.get( 0 );
    Path pathCommand = IO.path(cmd);
    if ( !Files.exists( pathCommand ) ) {
        for ( Path dir : path ) {
            pathCommand = IO.path( dir, cmd );
            if ( Files.exists( pathCommand ) ) {
                cmd = pathCommand.toAbsolutePath().toString();
                break;
            }
        }
    }
    commandLine.set( 0, cmd );

}
 
开发者ID:advantageous,项目名称:boon,代码行数:16,代码来源:Runner.java

示例9: puts

import io.advantageous.boon.core.IO; //导入依赖的package包/类
/**
 * Like print, but prints out a whole slew of objects on the same line.
 *
 * @param messages objects you want to print on the same line.
 */
public static void puts(Object... messages) {

    for (Object message : messages) {
        IO.print(message);
        if (!(message instanceof Terminal.Escape)) IO.print(' ');
    }
    IO.println();

}
 
开发者ID:advantageous,项目名称:boon,代码行数:15,代码来源:Terminal.java

示例10: handle

import io.advantageous.boon.core.IO; //导入依赖的package包/类
public void handle( HttpExchange t ) throws IOException {

            InputStream requestBody = t.getRequestBody();
            String body = IO.read( requestBody );
            Headers requestHeaders = t.getRequestHeaders();
            body = body + "\n" + copy( requestHeaders ).toString();
            t.sendResponseHeaders( 200, body.length() );
            OutputStream os = t.getResponseBody();
            os.write( body.getBytes() );
            os.close();
        }
 
开发者ID:advantageous,项目名称:boon,代码行数:12,代码来源:HTTPTest.java

示例11: writeValue

import io.advantageous.boon.core.IO; //导入依赖的package包/类
@Override
public void writeValue( File dest, Object value ) {
    IO.write( Paths.get(dest.toString()), serializerFactory.create().serialize(value).toString());
}
 
开发者ID:advantageous,项目名称:boon,代码行数:5,代码来源:ObjectMapperImpl.java

示例12: parse

import io.advantageous.boon.core.IO; //导入依赖的package包/类
public <T> T parse( Class<T> type, InputStream input ) {
    return parse( type, IO.input(input) );
}
 
开发者ID:advantageous,项目名称:boon,代码行数:4,代码来源:JsonBaseByteArrayParser.java

示例13: parseFile

import io.advantageous.boon.core.IO; //导入依赖的package包/类
public <T> T parseFile( Class<T> type, String fileName ) {
    return parse(type, IO.input ( fileName ));
}
 
开发者ID:advantageous,项目名称:boon,代码行数:4,代码来源:JsonBaseByteArrayParser.java

示例14: part9Options

import io.advantageous.boon.core.IO; //导入依赖的package包/类
public static void part9Options() throws Exception {

        puts ("\n\n\n", "\npart9Options");


        JsonParserFactory jsonParserFactory = new JsonParserFactory()
                .useFieldsFirst().useFieldsOnly().usePropertiesFirst().usePropertyOnly() //one of these
                .lax() //allow loose parsing of JSON like JSON Smart
                .strict() //opposite of lax
                .setCharset( StandardCharsets.UTF_8 ) //Set the standard charset, defaults to UTF_8
                .setChop( true ) //chops up buffer overlay buffer (more discussion of this later)
                .setLazyChop( true ) //similar to chop but only does it after map.get
                ;

        JsonSerializerFactory jsonSerializerFactory = new JsonSerializerFactory()
                .useFieldsFirst().useFieldsOnly().usePropertiesFirst().usePropertyOnly() //one of these
                //.addPropertySerializer(  )  customize property output
                //.addTypeSerializer(  )      customize type output
                .useJsonFormatForDates() //use json dates
                //.addFilter(  )   add a property filter to exclude properties
                .includeEmpty().includeNulls().includeDefaultValues() //override defaults
                .handleComplexBackReference() //uses identity map to track complex back reference and avoid them
                .setHandleSimpleBackReference( true ) //looks for simple back reference for parent
                .setCacheInstances( true ) //turns on caching for immutable objects
                ;



        final User diana = BeanUtils.copy( user );
        final User rick = BeanUtils.copy( user );
        diana.getName().setFirst( "Diana" );
        diana.setGender( User.Gender.FEMALE );
        rick.getName().setFirst( "Rick" );
        diana.setBirthDate( Dates.getUSDate( 8, 21, 1984 ) );
        List<User> users = Lists.list(  rick, diana );

        //You can use parser and serializer directly.
        final JsonParserAndMapper jsonParserAndMapper = jsonParserFactory.create();
        final JsonSerializer jsonSerializer = jsonSerializerFactory.create();

        File file = File.createTempFile( "userList", ".json" );
        String jsonString = jsonSerializer.serialize( users ).toString();

        puts( "JSON STRING", jsonString );

        IO.write( file.toString(), jsonString);
        List<User> users2 = jsonParserAndMapper.parseListFromFile( User.class, file.toString() );

        //Or you can pass them to the ObjectMapper interface you know and love, just pass the factories to it.
        ObjectMapper mapper = JsonFactory.create( jsonParserFactory, jsonSerializerFactory );


        mapper.writeValue( file, users  );
        List<User> userList = mapper.readValue( file, List.class, User.class  );
        puts (userList);
        puts ( mapper.writeValueAsString( userList ) );

        puts (userList);
        puts (users);
        boolean ok = userList.toString().equals ( users.toString() ) || die ( userList.toString() );



    }
 
开发者ID:advantageous,项目名称:boon,代码行数:65,代码来源:JsonTutorial.java

示例15: test

import io.advantageous.boon.core.IO; //导入依赖的package包/类
@Test
public void test() {

    List<String> files  = IO.listByFileExtension ( "./files/", "json" );

    for ( String file : files) {
        //outputs ( file );

        Object object  =  new JsonParserFactory().createFastParser().parseFile ( Map.class, file.toString () );


        walkObject( object, null, null );

    }

    //outputs ( "leaf", leafCount, "map", mapCount, "collection", collectionCount );
    //outputs ( "integer", integerCount, "long", longCount, "double", doubleCount, "boolean", booleanCount );
    //outputs ( "string", stringCount, "date", dateCount, "null", nullCount );

}
 
开发者ID:advantageous,项目名称:boon,代码行数:21,代码来源:LazyValueMapTest.java


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