小编Gür*_*tak的帖子

在html中读取上传的文本文件内容

我想用html显示上传文件的内容,我只需上传一个文本文件.我的example.html:

<html xmlns="http://www.w3.org/1999/xhtml" >
<p>
Please specify a file, or a set of files:<br>
<input type="file" name="datafile" size="40">
</p>

<textarea id="2" name="y" style="width:400px;height:150px;"></textarea>
</html>
Run Code Online (Sandbox Code Playgroud)

如何在textarea中显示任何上传的文本文件的内容如下所示? 截图

html javascript file-upload file

22
推荐指数
3
解决办法
4万
查看次数

在运行时运行编译的java代码

我想运行之前编译的代码.我编译无论如何编译并不重要,但运行代码是问题.

我的 code.java

public class code{

    public static void main(String[] args) {
        System.out.println("Hello, World");
    }
}
Run Code Online (Sandbox Code Playgroud)

然后我编译了这段代码并code.class在(在D://目录中)生成了.现在我想运行这个编译文件.我的代码是:

import java.io.IOException;
import java.io.InputStream;

public class compiler {
   public static void main(String[] args) {
      final String dosCommand = "cmd /c java code";
      final String location = "D:\\";
      try {
         final Process process = Runtime.getRuntime().exec(
            dosCommand + " " + location);
         final InputStream in = process.getInputStream();
         int ch;
         while((ch = in.read()) != -1) {
            System.out.print((char)ch);
         }
      } catch (IOException e) …
Run Code Online (Sandbox Code Playgroud)

java cmd runtime

7
推荐指数
1
解决办法
172
查看次数

Stetho,没有看到检查链接

在此处输入图片说明

正如您在图片中看到的,没有看到检查链接。我在这个答案中做了步骤:https : //stackoverflow.com/a/32173974/5118976 在我的手机上运行应用程序后,但没有检查链接。为什么会出现这个问题?怎么解决?

database android stetho

5
推荐指数
1
解决办法
1448
查看次数

如何使用CoordinatorLayout将admob横幅放到屏幕底部

我使用CoordinatorLayout在activity_main.xml文件中创建滑动选项卡.我想把admob横幅放到屏幕的底部.但我有一个问题,当我尝试在下面编码时(activity_main.xml)Admob横幅显示在屏幕顶部而非屏幕底部.事实上,我认为这个admob显示在工具栏的底部(如图所示).但我想展示整个屏幕的底部

       <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        xmlns:ads="http://schemas.android.com/tools"
        >

  <-- Admob banner:
-->
        <com.google.android.gms.ads.AdView
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="@string/banner_home_footer">

        </com.google.android.gms.ads.AdView>

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                android:background="?attr/colorPrimary"
                app:layout_scrollFlags="scroll|enterAlways"
                app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                app:tabMode="fixed"
                app:tabGravity="fill"/>

        </android.support.design.widget.AppBarLayout>

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"

            />

    </android.support.design.widget.CoordinatorLayout>
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

layout android banner admob android-coordinatorlayout

5
推荐指数
2
解决办法
5396
查看次数

java中的文件类型(Windows,unix)

我实现了一个从命令行获取输入文件的代码.然后,对此输入进行排序.然后将输出写入当前目录.我的代码工作,但我想知道该类型的文件.我的input.txt类型是dos\Windows,如图所示.我生成的output.txt类型是UNIX.它们的尺寸也不同.为什么它们以不同的格式存储?我使用bufferedReader,fileWriter来实现这段代码.

code.java:

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Arrays;
import java.io.FileWriter;

public class code{

    public static void main(String[] args) {


        try (BufferedReader br = new BufferedReader(new FileReader(args[0])))
        {

            int lines = 0;
            while (br.readLine() != null) lines++; // to get text's number of lines 

            String sCurrentLine;
            BufferedReader br2 = new BufferedReader(new FileReader(args[0])); //to read and sort the text

            String[] array; //create a new array
            array = new String[lines];

            int i=0;
            while ((sCurrentLine = br2.readLine()) != null) {//fill array with …
Run Code Online (Sandbox Code Playgroud)

java file-io operating-system filewriter bufferedreader

2
推荐指数
1
解决办法
1013
查看次数

HTML中所有页面的背景图像

有没有办法将默认背景图像插入到所有页面的HTML中.所有页面都需要相同的背景.逐页添加背景对我来说很难,因为我有35页.我正在使用JSP.

html css jsp background-image

0
推荐指数
1
解决办法
1213
查看次数

为什么这段代码片段包含错误?

我通常知道,*和&符号.但我们的老师给了我们一个例子,她说"问题发生在这里"

int *a1;
int *a2 = new int[100];
a1=a2 //What does this line mean???
delete []a2;

k=a1[0]//she said error occurs here.
Run Code Online (Sandbox Code Playgroud)

我无法理解什么是a1 = a2?为什么会出现错误?

c++ pointers assignment-operator delete-operator

-9
推荐指数
1
解决办法
82
查看次数