精华内容
下载资源
问答
  • Java中CharArrayWriter类的writeTo(Writer)方法用于将CharArrayWriter内容写入另一个字符流。public void writeTo(Writer out)throws IOException参数:此方法接受一个代表输出流参数,该输出流是目标流。返回值...

    Java中CharArrayWriter类的writeTo(Writer)方法用于将CharArrayWriter的内容写入另一个字符流。

    public void writeTo(Writer out)

    throws IOException

    参数:此方法接受一个代表输出流的参数,该输出流是目标流。返回值:此方法不返回任何值。异常:如果发生I /O错误,此方法将引发IOException。下面的程序演示了writeTo(Writer)方法在IO包的CharArrayWriter类中:程序1:

    Java

    // Java program to illustrate

    // CharArrayWriter writeTo(Writer) method

    import java.io.*;

    public class GFG {

    public static void main(String[] args)

    throws IOException

    {

    // Create charArrayWriter

    CharArrayWriter charArrayWriter

    = new CharArrayWriter();

    String str = "GEEKS";

    charArrayWriter.write(str);

    // Create outputStream

    CharArrayWriter out

    = new CharArrayWriter();

    charArrayWriter.writeTo(out);

    // print the outputStream

    System.out.println(

    out.toString());

    }

    }

    输出:

    GEEKS

    程序2:

    Java

    // Java program to illustrate

    // CharArrayWriter writeTo(Writer) method

    import java.io.*;

    public class GFG {

    public static void main(String[] args)

    throws IOException

    {

    // Create charArrayWriter

    CharArrayWriter charArrayWriter

    = new CharArrayWriter();

    charArrayWriter.write("GEEKSFORGEEKS");

    // Create outputStream

    CharArrayWriter out

    = new CharArrayWriter();

    charArrayWriter.writeTo(out);

    // print the outputStream

    System.out.println(

    out.toString());

    }

    }

    输出:

    GEEKSFORGEEKS

    展开全文
  • write to 两种不同用法之间区别

    1.用write var to target中var可以是其他类型target限定字符型,但write (var) to target此时var和target都必须是字符型

    2.用write (var) to target会把var对应的变量的值赋给target.

    以下程序能说明问题

     REPORT demo_data_write .
    DATA: number TYPE VALUE '4.3',
          text(10) TYPE c,
          float TYPE f,
          pack  TYPE DECIMALS 1.
    WRITE number.
    WRITE number TO text EXPONENT 2.
    WRITE / text.
    MOVE number TO pack.
    WRITE / pack.
    ULINE.
    DATA: name(10)   TYPE VALUE 'SOURCE',
          source(10) TYPE VALUE 'Antony',
          target(10) TYPE c.
    WRITE (name) TO target.
    WRITE target.

     

    展开全文
  • Java中Writer类的write(String)方法用于在流上写入指定的String。该字符串值用作参数。用法:public void write(String string)...以下方法说明了write(String)方法的用法:示例1:// Java program to demonstrate// W...

    Java中Writer类的write(String)方法用于在流上写入指定的String。该字符串值用作参数。

    用法:

    public void write(String string)

    参数:此方法接受必需的参数字符串,该字符串是要写入流中的字符串。

    返回值:此方法不返回任何值。

    以下方法说明了write(String)方法的用法:

    示例1:

    // Java program to demonstrate

    // Writer write(String) method

    import java.io.*;

    class GFG {

    public static void main(String[] args)

    {

    try {

    // Create a Writer instance

    Writer writer

    = new PrintWriter(System.out);

    // Write the String 'GeeksForGeeks'

    // to this writer using write() method

    // This will put the string in the stream

    // till it is printed on the console

    writer.write("GeeksForGeeks");

    writer.flush();

    }

    catch (Exception e) {

    System.out.println(e);

    }

    }

    }

    输出:

    GeeksForGeeks

    示例2:

    // Java program to demonstrate

    // Writer write(String) method

    import java.io.*;

    class GFG {

    public static void main(String[] args)

    {

    try {

    // Create a Writer instance

    Writer writer

    = new PrintWriter(System.out);

    // Write the String 'GFG'

    // to this writer using write() method

    // This will put the string in the stream

    // till it is printed on the console

    writer.write("GFG");

    writer.flush();

    }

    catch (Exception e) {

    System.out.println(e);

    }

    }

    }

    输出:

    GFG

    展开全文
  • 如果您正苦於以下問題:Java JavaFile.writeTo方法具體用法?Java JavaFile.writeTo怎麽用?Java JavaFile.writeTo使用例子?那麽恭喜您, 這裏精選方法代碼示例或許可以為您提供幫助。您也可以進一步了解該...

    本文整理匯總了Java中com.squareup.javapoet.JavaFile.writeTo方法的典型用法代碼示例。如果您正苦於以下問題:Java JavaFile.writeTo方法的具體用法?Java JavaFile.writeTo怎麽用?Java JavaFile.writeTo使用的例子?那麽恭喜您, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.squareup.javapoet.JavaFile的用法示例。

    在下文中一共展示了JavaFile.writeTo方法的19個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於我們的係統推薦出更棒的Java代碼示例。

    示例1: constructActivityModule

    ​點讚 3

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    private void constructActivityModule() {

    final TypeSpec.Builder builder = TypeSpec.classBuilder(Constants.ACTIVITY_MODULE)

    .addModifiers(Modifier.PUBLIC, Modifier.ABSTRACT)

    .addAnnotation(Constants.DAGGER_MODULE);

    for (ActivityHolder activityHolder : activityHolders.values()) {

    builder.addMethod(MethodSpec.methodBuilder(Constants.METHOD_CONTRIBUTE + activityHolder.className)

    .addAnnotation(Constants.DAGGER_ANDROID_ANNOTATION)

    .addModifiers(Modifier.ABSTRACT)

    .returns(activityHolder.classNameComplete)

    .build()

    );

    }

    final TypeSpec newClass = builder.build();

    final JavaFile javaFile = JavaFile.builder(Constants.PACKAGE_NAME, newClass).build();

    try {

    javaFile.writeTo(System.out);

    javaFile.writeTo(filer);

    } catch (IOException e) {

    e.printStackTrace();

    }

    }

    開發者ID:florent37,項目名稱:DaggerAutoInject,代碼行數:25,

    示例2: process

    ​點讚 3

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    @Override

    public boolean process(Set extends TypeElement> set, RoundEnvironment roundEnvironment) {

    parser.scan(roundEnvironment);

    TypeSpec.Builder builder = TypeSpec.classBuilder("Testing")

    .addModifiers(Modifier.PUBLIC, Modifier.FINAL);

    for (Element element : roundEnvironment.getElementsAnnotatedWith(Parse.class))

    builder.addField(FieldSpec.builder(String.class, element.getSimpleName().toString())

    .addModifiers(Modifier.PRIVATE, Modifier.FINAL)

    .initializer("$S", parser.parse("com.example.rparser", element.getAnnotation(Parse.class).value()))

    .build());

    JavaFile javaFile = JavaFile.builder("com.example.rparser", builder.build())

    .build();

    try {

    javaFile.writeTo(filer);

    } catch (IOException ignored) {

    }

    return false;

    }

    開發者ID:hendraanggrian,項目名稱:r-parser,代碼行數:19,

    示例3: generate

    ​點讚 3

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    public static void generate(Domain ontology, Path outputDirectory) throws IOException {

    JavaFile tags = TagGenerator.tag(ontology);

    JavaFile marker = MarkerGenerator.marker(ontology);

    JavaFile builder = MarkerGenerator.markerBuilder(ontology);

    JavaFile statement = LoggerGenerator.statement(ontology);

    JavaFile logger = LoggerGenerator.logger(ontology);

    JavaFile mdc = MdcGenerator.statement(ontology);

    Files.createDirectories(outputDirectory);

    for(JavaFile file : new JavaFile[]{tags, marker, builder, statement, logger, mdc}) {

    if(file != null) {

    if(changed(file, outputDirectory)) {

    file.writeTo(outputDirectory);

    } else {

    // do not write this file

    }

    }

    }

    }

    開發者ID:skjolber,項目名稱:json-log-domain,代碼行數:21,

    示例4: writeBinding

    ​點讚 3

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    private void writeBinding(String targetClassName, Set annotationFields)

    throws IOException {

    String packageName = null;

    int lastDot = targetClassName.lastIndexOf('.');

    if (lastDot > 0) {

    packageName = targetClassName.substring(0, lastDot);

    }

    String targetSimpleClassName = targetClassName.substring(lastDot + 1);

    String bindingClassName = targetClassName + "_PrefBinding";

    String bindingSimpleClassName = bindingClassName.substring(lastDot + 1);

    ClassName targetClass = ClassName.get(packageName, targetSimpleClassName);

    TypeSpec binding = TypeSpec.classBuilder(bindingSimpleClassName)

    .addModifiers(Modifier.PUBLIC)

    .addMethod(buildConstructor(targetClass, annotationFields))

    .build();

    JavaFile javaFile = JavaFile.builder(packageName, binding).build();

    javaFile.writeTo(processingEnv.getFiler());

    }

    開發者ID:quangctkm9207,項目名稱:prefpin,代碼行數:24,

    示例5: generateSharedProperties

    ​點讚 3

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    public static boolean generateSharedProperties(Collection fields,

    Elements elements, Filer filer, ProcessorPrinter pp){

    final ClassName cn_sp = ClassName.get(PKG_DM_INTERNAL, SIMPLE_NAME_SHARED_PROP);

    CodeBlock.Builder staticBuilder = CodeBlock.builder();

    for(FieldData fd : fields){

    staticBuilder.add("$T.putToCache($S, $S, $L);\n", cn_sp, fd.getTypeCompat().toString(),

    fd.getPropertyName(), fd.getComplexType());

    }

    String classSimpleName = SIMPLE_NAME_SHARED_PROP + "_" + findBestIndex(elements);

    TypeSpec typeSpec = TypeSpec.classBuilder(classSimpleName)

    .addModifiers(Modifier.PUBLIC, Modifier.FINAL)

    .addStaticBlock(staticBuilder.build())

    .addJavadoc(CodeBlock.of(DOC))

    .build();

    try {

    JavaFile javaFile = JavaFile.builder(PKG_DM_INTERNAL, typeSpec)

    .build();

    // System.out.println(javaFile.toString());

    javaFile.writeTo(filer);

    } catch (IOException e) {

    pp.error(TAG, "generateSharedProperties", Util.toString(e));

    return false;

    }

    return true;

    }

    開發者ID:LightSun,項目名稱:data-mediator,代碼行數:27,

    示例6: process

    ​點讚 3

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    @Override

    public boolean process(Set extends TypeElement> typeElements, RoundEnvironment roundEnv) {

    if (typeElements.size() == 0) {

    return true;

    }

    for (TypeElement typeElement : typeElements) {

    for (Element element : roundEnv.getElementsAnnotatedWith(typeElement)) {

    T entity = element.getAnnotation(targetAnnotation());

    SourceGenerator generator = createGenerator(element, entity, roundEnv);

    Filer filer = super.processingEnv.getFiler();

    try {

    List javaFile = generator.createJavaFile(element);

    for (JavaFile file : javaFile) {

    file.writeTo(filer);

    }

    } catch (IOException e) {

    e.printStackTrace();

    }

    }

    }

    return false;

    }

    開發者ID:orekyuu,項目名稱:Moco,代碼行數:24,

    示例7: generateCode

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    private void generateCode(ClassInfo classInfo, List properties)

    throws IOException, ReactPropertyException {

    MethodSpec getMethods = MethodSpec.methodBuilder("getProperties")

    .addModifiers(PUBLIC)

    .addAnnotation(Override.class)

    .addParameter(PROPERTY_MAP_TYPE, "props")

    .returns(TypeName.VOID)

    .addCode(generateGetProperties(properties))

    .build();

    TypeName superType = getSuperType(classInfo);

    ClassName className = classInfo.mClassName;

    String holderClassName =

    getClassName((TypeElement) classInfo.mElement, className.packageName()) + "$$PropsSetter";

    TypeSpec holderClass = TypeSpec.classBuilder(holderClassName)

    .addSuperinterface(superType)

    .addModifiers(PUBLIC)

    .addMethod(generateSetPropertySpec(classInfo, properties))

    .addMethod(getMethods)

    .build();

    JavaFile javaFile = JavaFile.builder(className.packageName(), holderClass)

    .addFileComment("Generated by " + getClass().getName())

    .build();

    javaFile.writeTo(mFiler);

    }

    開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:29,

    示例8: generateJava

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    private void generateJava(String packageName, String pluginName, File target) {

    List collector = new ArrayList();

    TypeGenerator.generate(packageName, model, collector);

    IndexGenerator.generate(packageName, model, collector);

    ConstantGenerator.generate(packageName, model, collector);

    PluginGenerator.generate(packageName, pluginName, model, collector);

    for (JavaFile file : collector) {

    try {

    file.writeTo(target);

    } catch (IOException e) {

    e.printStackTrace();

    }

    }

    }

    開發者ID:datathings,項目名稱:greycat,代碼行數:15,

    示例9: generateClass

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    /**

    * Generates the code for the Barricade configuration based on the annotations found.

    *

    * @param processingEnv Processing environment

    * @param configs Configuration detected by annotation processing

    * @param messager Messager to print logs

    * @throws IOException

    */

    static void generateClass(ProcessingEnvironment processingEnv,

    HashMap configs, Messager messager) throws IOException {

    messager.printMessage(Diagnostic.Kind.NOTE, "Generating configuration code...");

    TypeSpec.Builder classBuilder = classBuilder(CLASS_NAME).addModifiers(PUBLIC, FINAL);

    FieldSpec valuesField = FieldSpec.builder(TYPE_CONFIG, "configs").addModifiers(PRIVATE).build();

    FieldSpec instanceField =

    FieldSpec.builder(ClassName.get(PACKAGE_NAME, CLASS_NAME), "barricadeConfig")

    .addModifiers(PRIVATE, STATIC)

    .build();

    MethodSpec.Builder instanceMethodBuilder = generateGetInstanceMethodBuilder();

    MethodSpec.Builder constructorMethodBuilder = generateConstructorBuilder(configs, messager);

    MethodSpec.Builder valuesMethod = generateGetConfigsMethodBuilder();

    MethodSpec.Builder getResponseMethodBuilder = generateGetResponseMethodBuilder();

    classBuilder.addType(generateEndpointsInnerClass(configs.keySet()));

    classBuilder.addType(generateResponsesInnerClass(configs));

    classBuilder.addField(instanceField);

    classBuilder.addField(valuesField);

    classBuilder.addMethod(instanceMethodBuilder.build());

    classBuilder.addMethod(constructorMethodBuilder.build());

    classBuilder.addMethod(valuesMethod.build());

    classBuilder.addMethod(getResponseMethodBuilder.build());

    classBuilder.addSuperinterface(IBarricadeConfig.class);

    JavaFile.Builder javaFileBuilder = builder(PACKAGE_NAME, classBuilder.build());

    JavaFile javaFile = javaFileBuilder.build();

    javaFile.writeTo(processingEnv.getFiler());

    messager.printMessage(Diagnostic.Kind.NOTE, "Code generation complete!");

    }

    開發者ID:mutualmobile,項目名稱:Barricade,代碼行數:44,

    示例10: writeRxObserve

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    private void writeRxObserve() {

    final TypeSpec.Builder builder = TypeSpec.classBuilder(Constants.CLASS)

    .addModifiers(Modifier.PUBLIC);

    for (ClassName className : observeHolders.keySet()) {

    final ObserveHolder observeHolder = observeHolders.get(className);

    final String simpleName = className.simpleName();

    final TypeName returnType = ClassName.bestGuess(className.packageName() + "." + simpleName + Constants.OBSERVE_CLASS);

    if (processUtils.allMethodsAreStatic(observeHolder.methods)) {

    builder.addMethod(MethodSpec.methodBuilder(Constants.METHOD_OF + simpleName)

    .addModifiers(Modifier.PUBLIC, Modifier.STATIC)

    .returns(returnType)

    .addStatement("return new $T()", returnType)

    .build());

    } else {

    builder.addMethod(MethodSpec.methodBuilder(Constants.METHOD_OF)

    .addModifiers(Modifier.PUBLIC, Modifier.STATIC)

    .addParameter(className, Constants.TARGET)

    .returns(returnType)

    .addStatement("return new $T($L)", returnType, Constants.TARGET)

    .build());

    }

    }

    final TypeSpec newClass = builder.build();

    final JavaFile javaFile = JavaFile.builder(Constants.PACKAGE, newClass).build();

    try {

    javaFile.writeTo(System.out);

    javaFile.writeTo(filer);

    } catch (IOException e) {

    e.printStackTrace();

    }

    }

    開發者ID:florent37,項目名稱:Rx.Observe,代碼行數:37,

    示例11: process

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    @Override

    public boolean process(Set extends TypeElement> set, RoundEnvironment env) {

    List files = findAndParseTargets(env);

    for (JavaFile javaFile : files) {

    try {

    javaFile.writeTo(filer);

    } catch (IOException e) {

    error("Unable to write same name %s: %s", javaFile.packageName, e.getMessage());

    }

    }

    return false;

    }

    開發者ID:TangXiaoLv,項目名稱:Android-Router,代碼行數:13,

    示例12: createJavaFile

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    private void createJavaFile(String packageName, TypeSpec typeSpec) {

    try {

    JavaFile javaFile = JavaFile.builder(packageName, typeSpec)

    .build();

    javaFile.writeTo(processingEnv.getFiler());

    } catch (IOException ex) {

    processingEnv.getMessager()

    .printMessage(Diagnostic.Kind.ERROR, "It was not possible to generate java files due to an error: \n" + ex.getMessage());

    }

    }

    開發者ID:rsulkowski,項目名稱:jdoocsoup,代碼行數:11,

    示例13: writeSource

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    void writeSource(JavaFile file) {

    try {

    file.writeTo(env.getFiler());

    } catch (IOException e) {

    env.getMessager().printMessage(Diagnostic.Kind.ERROR, e.getMessage());

    }

    }

    開發者ID:hf,項目名稱:immu,代碼行數:8,

    示例14: process

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    @Override

    public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {

    Set factories = roundEnv.getElementsAnnotatedWith(InspectorFactory.class)

    .stream()

    .map((Function) element -> (TypeElement) element)

    .collect(Collectors.toSet());

    for (TypeElement factory : factories) {

    if (!implementsValidatorFactory(factory)) {

    error(factory, "Must implement Validator.Factory!");

    }

    List validationTargets =

    getTargetClasses(factory.getAnnotation(InspectorFactory.class)).flatMap(targetClass ->

    roundEnv.getElementsAnnotatedWith(

    targetClass)

    .stream())

    .map((Function) element -> {

    if (!(element instanceof TypeElement)) {

    throw new UnsupportedOperationException(

    "InspectorFactories can only operate on annotated types.");

    }

    return (TypeElement) element;

    })

    .collect(Collectors.toList());

    String adapterName = classNameOf(factory);

    String packageName = packageNameOf(factory);

    TypeSpec validatorFactory =

    createValidatorFactory(validationTargets, packageName, adapterName);

    JavaFile file = JavaFile.builder(packageName, validatorFactory)

    .build();

    try {

    file.writeTo(processingEnv.getFiler());

    } catch (IOException e) {

    processingEnv.getMessager()

    .printMessage(ERROR, "Failed to write ValidatorFactory: " + e.getLocalizedMessage());

    }

    }

    return false;

    }

    開發者ID:hzsweers,項目名稱:inspector,代碼行數:43,

    示例15: process

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    @Override

    public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {

    Set extends Element> reactModuleListElements = roundEnv.getElementsAnnotatedWith(

    ReactModuleList.class);

    for (Element reactModuleListElement : reactModuleListElements) {

    if (!(reactModuleListElement instanceof TypeElement)) {

    continue;

    }

    TypeElement typeElement = (TypeElement) reactModuleListElement;

    ReactModuleList reactModuleList = typeElement.getAnnotation(ReactModuleList.class);

    if (reactModuleList == null) {

    continue;

    }

    ClassName className = ClassName.get(typeElement);

    String packageName = ClassName.get(typeElement).packageName();

    String fileName = className.simpleName();

    List nativeModules = new ArrayList<>();

    try {

    reactModuleList.nativeModules(); // throws MirroredTypesException

    } catch (MirroredTypesException mirroredTypesException) {

    List extends TypeMirror> typeMirrors = mirroredTypesException.getTypeMirrors();

    for (TypeMirror typeMirror : typeMirrors) {

    nativeModules.add(typeMirror.toString());

    }

    }

    MethodSpec getReactModuleInfosMethod;

    try {

    getReactModuleInfosMethod = MethodSpec.methodBuilder("getReactModuleInfos")

    .addAnnotation(Override.class)

    .addModifiers(PUBLIC)

    .addCode(getCodeBlockForReactModuleInfos(nativeModules))

    .returns(MAP_TYPE)

    .build();

    } catch (ReactModuleSpecException reactModuleSpecException) {

    mMessager.printMessage(ERROR, reactModuleSpecException.mMessage);

    return false;

    }

    TypeSpec reactModulesInfosTypeSpec = TypeSpec.classBuilder(

    fileName + "$$ReactModuleInfoProvider")

    .addModifiers(Modifier.PUBLIC)

    .addMethod(getReactModuleInfosMethod)

    .addSuperinterface(ReactModuleInfoProvider.class)

    .build();

    JavaFile javaFile = JavaFile.builder(packageName, reactModulesInfosTypeSpec)

    .addFileComment("Generated by " + getClass().getName())

    .build();

    try {

    javaFile.writeTo(mFiler);

    } catch (IOException e) {

    e.printStackTrace();

    }

    }

    return true;

    }

    開發者ID:qq565999484,項目名稱:RNLearn_Project1,代碼行數:63,

    示例16: process

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    @Override

    /**

    * 在這裏掃描和處理你的注解並生成Java代碼

    */

    public boolean process(Set extends TypeElement> set, RoundEnvironment roundEnvironment) {

    MethodSpec methodSpec_initUnitModels = processUnitElements(set, roundEnvironment);

    MethodSpec methodSpec_initUnitGroupModels = processUnitGroupElements(set, roundEnvironment);

    if (methodSpec_initUnitModels == null){

    mErrorReporter.reportWaring("methodSpec_initUnitModels is null.");

    }

    if (methodSpec_initUnitGroupModels == null){

    mErrorReporter.reportWaring("methodSpec_initUnitGroupModels is null.");

    }

    if (methodSpec_initUnitModels == null && methodSpec_initUnitGroupModels == null){

    mErrorReporter.reportWaring("methodSpec_initUnitModels && methodSpec_initUnitGroupModels is null.");

    return true;

    }

    MethodSpec methodSpec_createModelMap = InitMethodUtil.createMethodSpecBuilder_createModelMap().build();

    try {

    //聲明類DUnitManager_AutoImpl1,並添加方法

    ClassName typeName = ClassName.bestGuess(DUnitConstant.Sys.DUNIT_MANAGER_CANONICAL_NAME);

    TypeSpec.Builder typeSpecBuild_DUnitManager_AutoImpl = TypeSpec

    .classBuilder(DUnitConstant.Sys.DUNIT_MANAGER_AUTO_IMPL_SIMPLE_NAME)

    .addModifiers(Modifier.FINAL)

    .addModifiers(Modifier.PUBLIC)

    .superclass(typeName)

    .addMethod(methodSpec_createModelMap);

    if (methodSpec_initUnitModels != null){

    typeSpecBuild_DUnitManager_AutoImpl.addMethod(methodSpec_initUnitModels);

    }

    if (methodSpec_initUnitGroupModels != null){

    typeSpecBuild_DUnitManager_AutoImpl.addMethod(methodSpec_initUnitGroupModels);

    }

    TypeSpec typeSpec_DUnitManager_AutoImpl = typeSpecBuild_DUnitManager_AutoImpl.build();

    //創建Java文件

    JavaFile javaFile = JavaFile

    .builder(DUnitConstant.Sys.DUNIT_MANAGER_AUTO_IMPL_PKG, typeSpec_DUnitManager_AutoImpl)

    .addStaticImport(DUnitConstant.Sys.class,"DEFAULT_VALUE_GROUP_NAME")

    .build();

    javaFile.writeTo(processingEnv.getFiler());

    } catch (Exception e) {

    mErrorReporter.reportError("--------->" + e.getMessage());

    e.printStackTrace();

    throw new RuntimeException(e);

    }

    return true;

    }

    開發者ID:tik5213,項目名稱:DUnit,代碼行數:54,

    示例17: process

    ​點讚 2

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    @Override

    public boolean process(Set extends TypeElement> annotations, RoundEnvironment roundEnv) {

    StringBuilder switchCase = new StringBuilder();

    switchCase.append("switch (tag) {\n");

    for (Element element : roundEnv.getElementsAnnotatedWith(IsJob.class)) {

    if (element.getKind() == ElementKind.CLASS) {

    String className = elementUtils.getPackageOf(element).getQualifiedName().toString()

    + "." + element.getSimpleName();

    switchCase.append(" case ")

    .append(className)

    .append(".TAG:\n")

    .append(" return new ")

    .append(className)

    .append("();\n");

    }

    }

    switchCase.append(" default:\n" +

    " return null;\n" +

    " }\n");

    String jobPackage = "com.evernote.android.job";

    ClassName jobClass = ClassName.get(jobPackage, "Job");

    ClassName jobCreatorClass = ClassName.get(jobPackage, "JobCreator");

    MethodSpec createSpec = MethodSpec.methodBuilder("create")

    .addAnnotation(Override.class)

    .addModifiers(Modifier.PUBLIC)

    .addParameter(String.class, "tag")

    .returns(jobClass)

    .addCode(switchCase.toString())

    .build();

    TypeSpec jobSpec = TypeSpec.classBuilder("AppJobCreator")

    .addModifiers(Modifier.PUBLIC, Modifier.FINAL)

    .addAnnotation(BaseUtil.getGenerationDetails(JobAnnotationProcessor.class))

    .addSuperinterface(jobCreatorClass)

    .addMethod(createSpec)

    .build();

    JavaFile javaFile = JavaFile.builder(jobPackage, jobSpec)

    .build();

    try {

    javaFile.writeTo(filer);

    } catch (IOException e) {

    e.printStackTrace();

    }

    return true;

    }

    開發者ID:cyrilpillai,項目名稱:Android-Job-Helper,代碼行數:53,

    示例18: generateSender

    ​點讚 1

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    private void generateSender(TypeElement interfaceElement, PackageElement packageElement) throws IOException {

    SenderGenerator senderGenerator = new SenderGenerator(messager, interfaceElement)

    .generateInitializing()

    .generateMethods()

    .generateHandler();

    JavaFile senderFile = JavaFile.builder(packageElement.getQualifiedName().toString(), senderGenerator.buildClass()).build();

    senderFile.writeTo(filer);

    }

    開發者ID:nsforth,項目名稱:vxrifa,代碼行數:13,

    示例19: generateReceiver

    ​點讚 1

    import com.squareup.javapoet.JavaFile; //導入方法依賴的package包/類

    private void generateReceiver(TypeElement interfaceElement, PackageElement packageElement) throws IOException {

    ReceiverGenerator receiverGenerator = new ReceiverGenerator(messager, interfaceElement)

    .generateInitializing()

    .generateRegisterMethod()

    .generateUnregisterMethod();

    JavaFile receiverFile = JavaFile.builder(packageElement.getQualifiedName().toString(), receiverGenerator.buildClass()).build();

    receiverFile.writeTo(filer);

    }

    開發者ID:nsforth,項目名稱:vxrifa,代碼行數:13,

    注:本文中的com.squareup.javapoet.JavaFile.writeTo方法示例整理自Github/MSDocs等源碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。

    展开全文
  • .利用Python内置(Python脚本)工具,帮你自动转换...其中一个叫做2to3.py,就是用来帮你实现,将Python 2.x代码,转换为Python 3.x代码。其位置位于:Python安装根目录\Python27\Tools\Scripts\2to3.py【...
  • .利用Python内置(Python脚本)工具,帮你自动转换 ...其中一个叫做2to3.py,就是用来帮你实现,将Python 2.x代码,转换为Python 3.x代码。 其位置位于:Python安装根目录\Python27\To...
  • Java中的StringWriter类的write(String)方法用于在流上写入指定的String。该字符串值用作参数。用法:public void write(String ...以下示例程序旨在说明write(String)方法的用法:示例1:// Java program to demon...
  • .利用Python内置(Python脚本)工具,帮你自动转换...其中一个叫做2to3.py,就是用来帮你实现,将Python 2.x代码,转换为Python 3.x代码。其位置位于:Python安装根目录\Python27\Tools\Scripts\2to3.py【...
  • Java中PrintWriter类的write(String)方法用于在流上写入指定的String。该字符串值用作参数。用法:public void write(String string)...以下方法说明了write(String)方法的用法:示例1:// Java program to demonstrat...
  • 网友zsyyh提问:请问write_videofile和 to_videofile有什么区别吗?感觉用法一样 我之前没有遇到过还有to_videofile这样函数,于是查了下源码,发下下面说明 # ## # # The old functions to_videofile, to_gif...
  • session_write_close() 用法

    2014-07-02 20:07:00
    1.需要session控制大文件下载,防止因为占用session文件时间...session_write_close() worked as a lifesaver for me when automatically uploading files to a user (forcing a download instead of a link). If...
  • 在mysql数据库中 rank的用法的用法你知道吗?...在mysql数据库中 rank的用法的用法如下:Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. ...
  • MemoryStream 一些用法

    2019-09-27 15:22:35
    MemoryStream 一些用法The following code example shows how to read and write data using memory as a backing store.基本读写数据 The following code example shows how to read and write data using memory...
  • Write home是给家里写信、或者说写家信。Write home about就是:给家里写信时候谈到某件事。...据一些专家和学者考证,这种用法最早可能是一百年前从出国作战军人和远航水手那里流传出来。当时
  • DAC的用法

    千次阅读 2018-05-23 09:38:52
    基本用法from pyb import DACdac = DAC(1) # create DAC 1 on pin X5dac.write(128) # write a value to the DAC (makes X5 1.65V)dac = DAC(1, bits=12) # use 12 bit resolutiondac.write(4095)...
  • sprintf函数的用法

    万次阅读 2016-01-22 18:49:26
    function sprintf ...int sprintf ( char * str, const char * format, ......Write formatted data to string Composes a string with the same text that would be printed if format was used on p
  • Welcome to CSDN-------My First Time Write Blog New hand!!! 2019年7月纪中中集训自我总结 扎实程度: 完全掌握:A 大部分掌握:B 基本掌握:C 理解其中的用法和意义D 微微理解:E 几乎不理解:F 2019年07月 语言...
  • GNU+make中文手册V3.8 <=========From Docs==============> 一般我们可以使用“$(wildcard *.c)”来获取工作目录下所有.c 文件列表。复杂一些用法;可以使用“$(patsubst %.c,%.o,$(wi...
  • ABAP ASSIGN COMPONENT的用法 ASSIGN的用法分为静态和动态: 静态: FIELD-SYMBOLS <fs_field> TYPE any. DATA gv_char TYPE c LENGTH 20 VALUE '北京'. ASSIGN gv_char TO <fs_field>. WRITE:/ gv_...
  • DAC使用用法

    千次阅读 2018-05-23 09:35:00
    基本用法from pyb import DACdac = DAC(1) # create DAC 1 on pin X5dac.write(128) # write a value to the DAC (makes X5 1.65V)dac = DAC(1, bits=12) # use 12 bit resolutiondac.wri...
  • python中argparse用法

    2018-12-22 15:54:20
    python中argparse用法(实例) The argparse module makes it easy to write user-friendly command-line interfaces. The program defines what arguments it requires, and argparse will figure out how to ...
  • mysql报错如下: Can't create/write to file '/tmp/#sql_118c_0.MYI' (Errcode: 28); 本以为很简单,google,找到confluence官网,有该问题描述、出现原因及其解决方案; ...
  • java中讲讲FileWriter的用法 FileWriter的用法 马克- to-win:马克 java社区:防盗版实名手机尾号: 73203。 FileWriter是Writer的继承类,从字面上就可看出,它的主要功能就是能向磁盘上写文件。write方法会把字符...
  • 在mysql数据库中 rank的用法的用法你知道吗?...在mysql数据库中 rank的用法的用法如下:Write a SQL query to rank scores. If there is a tie between two scores, both should have the same ranking. ...
  • 使用confluence创建文件时,...Can't create/write to file '/tmp/#sql_118c_0.MYI' (Errcode: 28); nested exception is java.sql.SQLException: Can't create/write to file '/tmp/#sql_118c_0.MYI' (Errcode: 28

空空如也

空空如也

1 2 3 4 5 ... 13
收藏数 241
精华内容 96
关键字:

to的用法write